I had to modify the print feature in our application in order to not print some specific pages. The only way I found that didn't requires heavy modifications was to recycle the page (I only know if the page need to be skipped after I "printed" it so I clear this page I use it again for the next). The problem is when the page I need to recycle is the last one I end up with a blank page for which I have no use. The clever trick I do at that point is to call Cancel on PrintEventArgs which effectively seems to cancel only the last page. Is that guaranteed to always be the case or I run the risk of cancelling more than the last page under some specific circumstances (ex: slow spooler)? I don't have any other fix in mind.
views:
29answers:
1
+1
A:
Yes, this should be a problem. Setting e.Cancel to true in the PrintPage event causes AbortDoc() to be called. From the SDK docs:
If Print Manager was used to start the print job, calling AbortDoc erases the entire spool job, so that the printer receives nothing. If Print Manager was not used to start the print job, the data may already have been sent to the printer. In this case, the printer driver resets the printer (when possible) and ends the print job.
Not actually sure what the "Print Manager" is. Ask at superuser.com
Hans Passant
2010-05-11 17:07:21
Then that pretty much mean that there is no way to cancel just one page.
Simon T.
2010-05-11 18:00:34
Right. You've already promised another page was coming by setting HasMorePages to true. PrintController committed to that and called StartPage(). That ship sailed.
Hans Passant
2010-05-11 19:01:42