Importing Pages

Use the ImportedPage class to import a page from an existing document as a template and add page elements to it.

ImportedPage

The ImportedPage class is a child of the Page class and represents an imported page. It inherits the Page class's properties and defines the following additional properties.

Properties

Property Description
BackgroundElements Gets a collection of page elements to be drawn as a background on the page.
ImportAllOtherData Gets or sets a value specifying whether or not to import all data except annotations and form fields.
ImportAnnotations Gets or sets a value specifying whether or not to import the annotations.
ImportFormFields Gets or sets a value specifying whether or not to import the form fields.
LogicalStructure Gets or sets a value specifying whether or not to import the logical structures.
UnderlyingElements Gets a collection of page elements that will appear beneath (behind) the page elements from the Elements property.

Example

An ImportedPage inherits the properties and methods of the Page class. After creating a new ImportedPage instance, add the needed elements via the Page class's Elements property by adding the required PageElement instances.

The following code imports a page and adds page elements to the page.

Document document = new Document();
ImportedPage page = new ImportedPage( pdfFilePath, 1 );
page.Elements.Add( new Label( "Label Text", 100, 100, 100, 12 ) );
page.Elements.Add( new Label( "Label Text2", 100, 120, 100, 12 ) );
document.Pages.Add( page );
document.Draw(pdfFilePath);        
Dim MyDocument As Document = New Document()
Dim MyPage As ImportedPage = New ImportedPage( pdfFilePath, 1 )
MyPage.Elements.Add( New Label( "Label Text", 100, 100, 100, 12 ) )
MyPage.Elements.Add( New Label( "Label Text2", 100, 120, 100, 12 ) )
MyDocument.Pages.Add( MyPage )
MyDocument.Draw(pdfFilePath)   

Importing Page From Stream

The following code shows how to import a page from a stream object.

Document document = new Document();
PdfDocument pdfDocument = new PdfDocument( stream );
ImportedPage page = new ImportedPage( pdfDocument.GetPage( 1 ) );
page.Elements.Add( new Label( "Label Text", 100, 100, 100, 12 ) );
page.Elements.Add( new Label( "Label Text2", 100, 120, 100, 12 ) );
document.Pages.Add( page );
document.Draw(pdfFilePath);        
Dim MyDocument As Document = New Document()
Dim MyPdfDocument As PdfDocument = New PdfDocument( MyStream )
Dim MyPage As ImportedPage = New ImportedPage( MyPdfDocument.GetPage(1) )
MyPage.Elements.Add( New Label( "Label Text", 100, 100, 100, 12 ) )
MyPage.Elements.Add( New Label( "Label Text2", 100, 120, 100, 12 ) )
MyDocument.Pages.Add( MyPage )
MyDocument.Draw(pdfFilePath)   

Refer to the ImportedPage API for a complete example.

In this topic