PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Alternate pages
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1812
Page 1 of 1

Author:  fuzzyexponent [ Mon Oct 10, 2011 12:24 pm ]
Post subject:  Alternate pages

I am creating a document in MigraDoc and would like to alternate pages between two distinct set ups. The specific scenario will probably make more sense:

I have an invoice print (not too dissimilar to the sample invoice project) where the invoice lines are in a table so that on reaching the end of the page it will automatically create a new one.

I have another section that defines a terms and conditions page that needs to appear after each invoice page (when on paper this gets duplexed on the back).

At the moment it just appears after the last page of the invoice and I'm not sure how to get around this.

I've had a number of thoughts about how this could be done but haven't been able to do so successfully yet.
1) Add something like the Odd/Even Headers and Footers that is already available but I'm yet to figure out where to implement it.
2) An option on the document to do one page from each section rather than a whole section at a time.
3) Find a way to override whatever function triggers the generation of a new page.
4) Possibly creating a footer with a page break so it becomes a page in itself.

Something I'd like to avoid if possible as it seems rather untidy
5) Create the document without the t&c pages and use PdfSharp to merge that document with another just containing the t&'s.

Any of these options will do however I'd definitely rather keep it all in MigraDoc if possible as everything so far has been purely MigraDoc.

I don't mind delving into the source code to get this working however I'm not sure where to look.

Has anybody had any success with anything similar?

Author:  Thomas Hoevel [ Mon Oct 10, 2011 3:10 pm ]
Post subject:  Re: Alternate pages

I think 5 is the tidiest way to get it going.

Here's a sample that calls docRenderer.RenderPage to create the pages as they are needed:
http://www.pdfsharp.net/wiki/MixMigraDo ... ample.ashx

You could optimize the filesize by using an XForm for the T&C pages - but I presume files will be printed, so filesize may not matter.

Author:  fuzzyexponent [ Mon Oct 10, 2011 3:52 pm ]
Post subject:  Re: Alternate pages

I feared that may be the case.

Due to the way the documents are going to be created and handled afterwards throughout the project I'm working on, I'd hoped to keep it within the MigraDoc Document format rather than the PdfSharp PdfDocument one.

I guess I can use an interface and some careful coding to deal with those issues.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/