View previous topic :: View next topic |
Author |
Message |
joshgerdes
Joined: 05 Feb 2009 Posts: 4
|
Posted: Thu Feb 05, 2009 10:22 pm Post subject: Copy / Duplicate page for multiple page document |
|
|
I am trying to create a document with multiple pages.
Each page has the same basic template with the only thing changing
between each page is small portion of text (for an address).
I was able to generate the initial page but I am having trouble
figuring out how to just duplicate that page with the base
content without having to generate the whole page.
Does anybody have any suggestions?
Thanks in advance. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Feb 09, 2009 11:17 am Post subject: |
|
|
I'd try calling "Clone()" for that page. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
joshgerdes
Joined: 05 Feb 2009 Posts: 4
|
Posted: Mon Feb 09, 2009 4:06 pm Post subject: |
|
|
The clone method returns a pdfdictionary and not a pdfpage.
So if you could let me know how to convert a pdfdictionary to a pdfpage then I think it would work. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Feb 09, 2009 4:32 pm Post subject: |
|
|
In C#:
Code: | PdfPage clone = (PdfPage)page.Clone(); |
_________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
joshgerdes
Joined: 05 Feb 2009 Posts: 4
|
Posted: Mon Feb 09, 2009 5:32 pm Post subject: |
|
|
Thanks. I did not know you could cast a pdfdictionary as a pdfpage.
I still have a problem though.
Even though I have a clone of the page it does not act as a separate object.
So when I add items to the original page it shows up on both pages.
I feel like I'm missing something simple here.
Any thoughts? |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Tue Feb 10, 2009 9:12 am Post subject: |
|
|
I thought that Clone() would give you a deep copy.
Maybe there's just a little thing missing ...
Different approach:
Create a PDF document with your template.
Create it in a memory stream (see WebSamples / Clock how to do it).
Then create an XPdfForm from that stream.
Draw this on every page of your final document and add the address later.
You have 10 or 15 lines of code instead of a simple Clone(), but it should work.
We do a similar thing all the time: we use a page from a PDF file as stationary for other documents. I also did it when I needed a letter with 1600 different addresses.
But there may be more efficient solutions. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
joshgerdes
Joined: 05 Feb 2009 Posts: 4
|
Posted: Wed Feb 18, 2009 7:53 pm Post subject: |
|
|
Thomas,
Thanks for the reply and idea for the different approach.
Do you think you could provide some sample code?
I tried the approach you suggested but I seem to be getting some errors
with the stream as it relates to the form.
I thought it would be more effective if just asked you for an example then
try and track down a working solution elsewhere.
Anything you can provide would be helpful.
Thanks in advance. |
|
Back to top |
|
|
|