Welcome Guest Search | Active Topics | Sign In | Register

Copy page from one Document to another Options
Dan
Posted: Monday, July 9, 2012 3:19:39 PM
Rank: Newbie
Groups: Member

Joined: 7/9/2012
Posts: 1
Hey All,

I'm trying to do something a little more advanced with EO.Pdf, and I'm not 100% sure if it's possible.

Basically, my ASP.net site is dynamically generating a PDF. Each page of that PDF wants to have a copy of a page from another PDF at about 90% scale (enough room to throw in a header).

Leaving aside the scaling for the moment, I tried getting the PdfContentCollection from each page and copying the content piece by piece into my new page. This would throw a Form Fields must be named error if the source PDF had fields OR would throw a "The object already has an owner. Please use a clone of the object instead." error if it didn't run into any form fields.

Code: C#
PdfDocument doc = new PdfDocument(HttpContext.Current.Server.MapPath("~/test.pdf"));
PdfContentCollection contentCollection = doc.Clone().Pages.First().Contents;
                        
foreach (PdfContent content in contentCollection)
{
     newPage.Contents.Add(content);
}


Does anyone have any thoughts on if this is possible - or why I am still getting a "owner / clone" error when I've cloned the document? Is there another approach I should try?

Thanks!
eo_support
Posted: Monday, July 9, 2012 3:38:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

You can only use PdfDocument.Merge to do that. You can never add a page of PdfDocument A into PdfDocument B.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.