I can\'t find documentation in PDFsharp to show how to add a 2nd page using C#!
As an example, over in VB6 I use a PDF creation method called mjwPDF. To indicate th
You create a new page with
document.AddPage();
and then call
XGraphics.FromPdfPage(page);
to get a gfx object for the second page (probably this is the missing step).
So repeat those steps from your code sample for every new page:
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
Update: In your loop you do the following:
document.AddPage();
XGraphics.FromPdfPage(page);
AddPage() returns a "handle" to the newly created page - which you throw in the bin. Then you call "XGraphics.FromPdfPage()" to create yet another gfx for the first page - which you also would throw in the bin, but you get an exception since there already is a gfx for the first page.
A small change should do the trick:
page = document.AddPage();
gfx = XGraphics.FromPdfPage(page);
See also: http://www.pdfsharp.net/wiki/PageSizes-sample.ashx
"I never dreamed adding a second page could be so difficult! No luck with the suggested code."
PDFsharp includes quite a few working samples to get people going. No luck with the suggested code since you ignored the important part - the values returned by the methods.