Print preview prints blank page

G

Guest

The print preview dialog will display the preview of the document but will
print a blank page when the print icon is clicked. Printing is fine
otherwise. Can i set the print icon in the printpreviewdialog to go to the
printdialog.
 
R

Ron Allen

Chase,
The print button just calls Print again on the PrintDocument. You need
to manage your datastream for the printing calls such that this resets the
data stream position to the start of your data. Providing an override for
OnBeginPrint is the standard way to do this.

Ron Allen
 
R

Ron Allen

Chase,
Since you are using a StreamReader you can just close it and reopen it.
Or just pass in the name of the text file and always open the stream in
OnBeginPrint and close it in OnEndPrint where you can also clean up
allocated fonts that you use.
Allocate/open things in OnBeginPrint and clean up everything in
OnEndPrint and you should have a document that doesn't leak any resources
and where the Print method can be called without a problem.

Ron Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top