예제 #1
0
        /// <summary>
        /// Helper function for ImportExternalPage.
        /// </summary>
        void CloneElement(PDFPage page, PDFPage importPage, string key, bool deepcopy)
        {
            Debug.Assert(page != null);
            Debug.Assert(page.Owner == _document);
            Debug.Assert(importPage.Owner != null);
            Debug.Assert(importPage.Owner != _document);

            PDFItem item = importPage.Elements[key];

            if (item != null)
            {
                PDFImportedObjectTable importedObjectTable = null;
                if (!deepcopy)
                {
                    importedObjectTable = Owner.ExternalDocumentTable.GetImportedObjectTable(importPage);
                }

                // The item can be indirect. If so, replace it by its value.
                if (item is PDFReference)
                {
                    item = ((PDFReference)item).Value;
                }
                if (item is PDFObject root)
                {
                    if (deepcopy)
                    {
                        Debug.Assert(root.Owner != null, "See 'else' case for details");
                        root = DeepCopyClosure(_document, root);
                    }
                    else
                    {
                        // The owner can be null if the item is not a reference.
                        if (root.Owner == null)
                        {
                            root.Document = importPage.Owner;
                        }
                        root = ImportClosure(importedObjectTable, page.Owner, root);
                    }

                    page.Elements[key] = root.Reference == null ? root : (PDFItem)root.Reference;
                }
                else
                {
                    // Simple items are just cloned.
                    page.Elements[key] = item.Clone();
                }
            }
        }
예제 #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;
            }

            if (!(item is PDFArray array))
            {
                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);
        }