Using PrintDocument1 and pdf files

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
Hi. I use PrintDocument1 and the e.Graphics.DrawString line to print listings of invoice details etc. from variables.
However, each page seems to start a new printrun (the Print Status thing from yesterday only ever said '...Page 1').

That doesn't matter for real printers and FinePrint (a virtual printer). The problem is that when the virtual printer is a pdf creator, it tries to create a new pdf output file for each page of a multi-page report, which is hopeless.

Is there a way of switching off the 'End Of Print Run' thing except when the print run has indeed ended, so that a multi-page report goes to a single multi-page pdf file?

Note: the 'e.HasMorePages = True/False' thing doesn't handle lots of individual variables per page, it seems designed for text (from a single large textbox) which spills over more than 1 page.

Also, Crystal Reports and similar things are not an option.

Thank you.
 
HasMorePages=True is the way to output multiple pages for a single print job. You can manage your data and variables any way you want to achieve this. If I had let's say a two page report with very different layout I would define two methods (like Sub Page1, Sub Page2) that I would call from the PrintPage handler, only the PrintPageEventArgs object would need to be passed to each method for them to have access to same event objects that the PrintPage method offers. Similarily, if there are standard elements in the reports like headers and footers that is repeated in different pages, refactor them out to separate methods.
 
Back
Top