PrintDocument, PrintPreviewDialog and Multiple Pages

If you are generating multiple pages in a document you set the e.HasMorePages to true, normally this is done by checking how many pages you have to print, e.g.

_CurrentPageNumber += 1
e.HasMorePages = _CurrentPageNumber


If the user then decides to Print the pages they are likely to only see the first page because the _CurrentPageNumber has not been reset to zero, as the Print command actually regenerates the pages by firing your code again not using what it has already created.

The tip here is to reset the controlling counter in the BeginPrint event


Leave a Reply