How can I programmatically copy & paste text from one PDF to another while preserving all formatting?

Q: Using PDFNET SDK, is there any way to programmatically copy & paste
text from one PDF to another PDF but retain style\location

I am trying to copy the headers and footers from one PDF to another
PDF. I can easily select the header\footer using a function like
PDFView.SelectByRect() and PDFView.GetSelection(). But how do I insert
\add the text in the exact position\style\layout into the destination
A: Given PDFView.GetSelection() you know the bounding boxes of all
selected content. You can copy the selected content to a temporary
page which you can then import to the target document. In case you
need to place this content on top of another PDF page you can use
ElementBuilder.CreateForm(page) as shown in ImpositionTest sample
project (

Now the only question is how do you selectively copy content from one
PDF page to another? As a starting point you may want to take a look
at ElementEdit sample project (
samplecode.html#ElementEdit) and more specifically RecolorPDFText from
PDFNet Forum ( - btw you will need to rename the file to zip).
To determine which content should be copied you could check if the
bbox for the current element overlaps any of the selection rectangles.
Actually, it is a bit trickier because skipping a text element could
affect the position of subsequent text elements (to avoid this you
would need to update text matrix as shown in RecolorPDFText).

A simpler option (if your import region is a rectangle) is that you
crop the input page (page.SetCropBox()) then import it into another
and place it on top of existing page using