We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Insert page from another PDF document

Hi,

I'm importing pages to a PdfDocument from a template PDF file located in the filesystem with the PdfDocument.ImportPage(...) method.

How can I insert such a loaded page at a specific position? The ImportPage(...) method just appends it.

The PdfDocument.Pages.Insert(...) method crashes, stating that the page already exists in another section.

Hope you can help me out, Regards


3 Replies

GM Geetha M Syncfusion Team May 31, 2011 06:03 AM UTC

Hi Guido,

Thank you for your interest in Syncfusion products.

You may create a PdfTemplate of the loaded page and draw at a new position in a new PdfDocument. Please refer to the code snippet given below:

PdfPage page = doc1.Pages.Add();
PdfGraphics g = page.Graphics;

PdfPageBase lpage = doc2.Pages[0];
PdfTemplate template = lpage.CreateTemplate();

g.DrawPdfTemplate(template, new PointF(100,100), page.GetClientSize());

Also, following is the link to our documentation which explains the same:
Import Pages As Templates
Please try this and let us know if you have any questions.

Regards,
Geetha



GS Guido Schrage May 31, 2011 08:42 AM UTC

Hi Geetha,

thanks for your response. I already read this solution, but what I don't mentioned in my first post (sorry) is that my PDF file template contains form fields and those get lost when just drawing an PdfTemplate on a new page.

I also don't know how to get the form fields of a specific page.

Any suggestions :) ?

Regards



GM Geetha M Syncfusion Team June 1, 2011 06:15 AM UTC

Hi Guido,

Thank you for the details.

Currently it is not possible to import an existing page with formfields based on position.

Please let us know if you have any questions.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon