コード例 #1
0
ファイル: PdfPage.cs プロジェクト: MykolaKovalchuk/SAE5
        /// <summary>
        /// Add all inheritable values from the specified page to the specified values structure.
        /// </summary>
        internal static void InheritValues(PdfDictionary page, ref InheritedValues values)
        {
            PdfItem item = page.Elements[InheritablePageKeys.Resources];

            if (item != null)
            {
                PdfReference reference = item as PdfReference;
                if (reference != null)
                {
                    values.Resources = (PdfDictionary)(reference.Value);
                }
                else
                {
                    values.Resources = (PdfDictionary)item;
                }
            }

            item = page.Elements[InheritablePageKeys.MediaBox];
            if (item != null)
            {
                values.MediaBox = new PdfRectangle(item);
            }

            item = page.Elements[InheritablePageKeys.CropBox];
            if (item != null)
            {
                values.CropBox = new PdfRectangle(item);
            }

            item = page.Elements[InheritablePageKeys.Rotate];
            if (item != null)
            {
                if (item is PdfReference)
                {
                    item = ((PdfReference)item).Value;
                }
                values.Rotate = (PdfInteger)item;
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the PdfRectangle class with the specified PdfArray.
        /// </summary>
        internal PdfRectangle(PdfItem item)
        {
            if (item == null || item is PdfNull)
            {
                return;
            }

            if (item is PdfReference)
            {
                item = ((PdfReference)item).Value;
            }

            PdfArray array = item as PdfArray;

            if (array == null)
            {
                throw new InvalidOperationException(PSSR.UnexpectedTokenInPdfFile);
            }

            _x1 = array.Elements.GetReal(0);
            _y1 = array.Elements.GetReal(1);
            _x2 = array.Elements.GetReal(2);
            _y2 = array.Elements.GetReal(3);
        }