Q: We need to put one PDF in Front of another PDF. One PDF contains
the form that has to be filled, the other contains the data. So this
would be the way to create one PDF that can be displayed or printed.
I tried around a lot an had some success. I read the two PDFs, load
the pages of the front PDF, cycle through the elements and place them
on the second element. It works fine for images. But text is scaled
wrong. Do you have a hint how i can merge two PDF pages into one PDF
A: Probably the simplest approach would be to add the PDF page with
static content to the PDF page with interactive forms.
You could possibly copy individual elements from one page to another,
but a simpler approach would be to create a form XObject using the
static PDF page, and than write the resulting element to the target
page (e.g. the page containing the interactive forms). ImpositionTest
(http://www.pdftron.com/net/samplecode.html#Imposition) shows how this
can be implemented. The code may look along the following lines:
Page existing_page = ...
ElementBuilder builder = new ElementBuilder();
ElementWriter writer = new ElementWriter();
// To write the page behind the (static) content of existing page pass
// as the second parameter to writer.Begin(existing_page, true).
Element element = builder.CreateForm(import_page, existing_page_doc);
double scale = Math.Min(existing_page.GetPageWidth()/
element.GetGState().SetTransform(scale, 0, 0, scale, pos_x, pos_y);
Yet another approach would be to copy annotations from one page to
another (in case the target page contains only interactive forms).