Importing Pages
Use the ImportedPage class to import a page from an existing document to a new document (Document class) or a merge document (MergeDocument).
Do not confuse ImportedPage with PdfPage. A PdfPage is a instance of a read-only page in a PdfDocument.
ImportedPage
The ImportedPage class is a child of the Page class and represents an imported page. It inherits the Page class's properties and has additional properties to exclude annotations and form fields (ImportAllOtherData
), import/exclude annotations (ImportAnnotations
), import/exclude form fields (ImportFormFields
), and import/exclude a page's logical structure (LogicalStructure
).
The ImportedPage also provides a property for getting a page's elements as background elements (BackgroundElements
) and getting a page's underlying elements (UnderlyingElements
).
Refer to the Adding New Content documentation page for an importing a page example.
Importing Background Elements
The following example illustrates getting an imported page's background elements and adding them to a page.
MergeDocument document = new MergeDocument();
ImportedPage importedPage = new ImportedPage("doc-text.pdf", 1);
Image image = new Image("large-logo.png"), 40, 150, .5F);
importedPage.BackgroundElements.Add(image);
Label lbl = new Label("Added Image", 100, 600, 400, 0);
lbl.FontSize = 56;
lbl.TextColor = RgbColor.Red;
importedPage.BackgroundElements.Add(lbl);
document.Pages.Add(importedPage);
document.Draw(outputPath);
Dim document As New MergeDocument()
Dim importedPage As New ImportedPage("doc-text.pdf", 1)
Dim image As New Image("large-logo.png"), 40, 150, 0.5F)
importedPage.BackgroundElements.Add(image)
Dim lbl As New Label("Added Image", 100, 600, 400, 0)
lbl.FontSize = 56
lbl.TextColor = RgbColor.Red
importedPage.BackgroundElements.Add(lbl)
document.Pages.Add(importedPage)
document.Draw(outputPath)
Figure 1. Importing a page and getting background elements.