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

Everything renders on 1st page of multi-page document
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2526
Page 1 of 1

Author:  davemick [ Tue Jul 23, 2013 2:55 pm ]
Post subject:  Everything renders on 1st page of multi-page document

Excuse me if I'm being thick (being a newbie).
I'm using PDFSharp in VB2010 Express to create a PDF file from a text file stream and some images.
I'm using gdx.DrawString and gdx.DrawImage
I increment my "Y" position for each line by the height of my font and, as expected everything looks fine.
Unfortunately, I'm having a problem when I want to use multiple pages.
I'm using the code:-
If (LocY + font.Height) > page.Height.Point Then
page = document.AddPage
LocY = 0
End If
to add a new page and reset my "Y" position when I have no more room on the page (this is within a loop for each line of text).
The saved PDF has the correct number of pages, but everything has been rendered onto the first page.
What am I doing wrong?

Author:  Thomas Hoevel [ Tue Jul 23, 2013 3:43 pm ]
Post subject:  Re: Everything renders on 1st page of multi-page document

You have to create a new "gdx" (or "gfx") for every new page.
You create a new page - but the old gfx continues to draw on the old page.

Author:  davemick [ Tue Jul 23, 2013 3:55 pm ]
Post subject:  Re: Everything renders on 1st page of multi-page document

Thanks for the speedy answer Thomas. All working brilliantly now :)

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