Placing Imported Pages

Use the ImportedPageArea and ImportedPageData classes to create a page element using the data from a page in an existing PDF document. These classes can then be rotated, scaled, or clipped and placed on a Page or ImportedPage.

The following code imports two pages and place them side by side on a new page.

Document document = new Document();
Page page = new Page( PageSize.Tabloid, PageOrientation.Landscape );
page.Elements.Add( new ImportedPageData( pdfFilePath, 1, -306, 0 ) );
page.Elements.Add( new ImportedPageData( pdfFilePath, 2, 306, 0 ) );
document.Pages.Add( page );
document.Draw(pdfFilePath);        
Dim MyDocument As Document = New Document()
Dim MyPage As Page = New Page( PageSize.Tabloid, PageOrientation.Landscape )
MyPage.Elements.Add( New ImportedPageData( pdfFilePath, 1, -306, 0 ) )
MyPage.Elements.Add( New ImportedPageData( pdfFilePath, 2, 306, 0 ) )
MyDocument.Pages.Add( MyPage )
MyDocument.Draw(pdfFilePath)   

The following code will import and clip a page and place it on a new page.

Document document = new Document();
Page page = new Page( PageSize.Tabloid, PageOrientation.Landscape );
ImportedPageArea importedPageArea = new ImportedPageArea( pdfFilePath, 1, 0, 0, 0.5f );
importedPageArea.Contents.ClipLeft = 100;
importedPageArea.Contents.ClipTop = 100;
importedPageArea.Contents.ClipRight = 100;
importedPageArea.Contents.ClipBottom = 100;
page.Elements.Add( importedPageArea );
document.Pages.Add( page );
document.Draw(pdfFilePath);        
Dim MyDocument As Document = New Document()
Dim MyPage As Page = New Page( PageSize.Tabloid, PageOrientation.Landscape )
Dim MyImportedPageArea As ImportedPageArea = New ImportedPageArea( pdfFilePath, 1, 0, 0, 0.5F )
MyImportedPageArea.Contents.ClipLeft = 100
MyImportedPageArea.Contents.ClipTop = 100
MyImportedPageArea.Contents.ClipRight = 100
MyImportedPageArea.Contents.ClipBottom  = 100
MyPage.Elements.Add( MyImportedPageArea )
MyDocument.Pages.Add( MyPage )
MyDocument.Draw(pdfFilePath)   

Page Content Reuse

When using the same page contents within the same document, it is important to only use an ImportedPageContents object once, and to then use it in the ImportedPageArea and ImportedPageData class constructors. Using these elements only once prevents embedding the page contents in a document multiple times and shares the data and reduces the overall size of your document.

The examples in this topic show how to import pages that are not reused multiple times. For details on how to most efficiently handle pages used multiple times, see the Performance Considerations topic.

In this topic