C# Print Preview
I am attempti开发者_运维技巧ng to create a preview of a letter my program automatically prints nightly. I have read a few articles, but still am having trouble understanding.
I understand I need to create a PrintPreviewDialog object, which I can call ShowDialog() on, once I've supplied it with a PrintDocument. My main question is, how do I create a PrintDocument?
I have all the information for the letter saved in separate variables, so I'll have to combine all of them, which is easy enough, but how do I change that object (StringBuilder) into a PrintDocument I can provide to the PrintPreviewDialog object?
As always, thanks for any help!
The print logic you have to put it inside a PrintPage event handler of the PrintDocument.
You can read http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx . It contains a complete example.
精彩评论