Copying pages between PDF documents can be seen as a special case of merging described in one of the earlier posts. A small piece of code below shows how to perform this task if you have only two PDF documents and want to copy a page from A to B.
public void CopyPDFPage()
// open documents
using (Stream s1 = File.OpenRead("source.pdf"),
s2 = new FileStream("destination.pdf",FileMode.Open,FileAccess.ReadWrite))
// create document objects
FixedDocument source = new FixedDocument(s1);
FixedDocument destination = new FixedDocument(s2);
// export first page from source doc and add to destination
// save changes as incremental update
The main step here, required to copy a Page (or any other resource) from one doc to another, is the call to the static Export method. PDF resources used on the particular PDF page (images, drawings, etc.) can be defined in various places across the document and referenced within the page’s content. These resources must be repacked in order to correctly copy the page. That’s what the Export() call does – it prepares the page and referenced resources for copying.