C# 打印预览
我正在尝试创建我的程序每晚自动打印的一封信的预览。我读过几篇文章,但仍然无法理解。
我知道我需要创建一个 PrintPreviewDialog 对象,一旦我向它提供了 PrintDocument,我就可以调用 ShowDialog() 。我的主要问题是,如何创建 PrintDocument?
我将字母的所有信息保存在单独的变量中,因此我必须将所有信息组合起来,这很容易,但是如何将该对象(StringBuilder)更改为可以提供给 PrintPreviewDialog 对象的 PrintDocument ?
一如既往,感谢您的帮助!
I am attempting 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将打印逻辑放入 PrintDocument 的 PrintPage 事件处理程序中。
您可以阅读 http://msdn.microsoft.com/ en-us/library/system.drawing.printing.printdocument.aspx 。它包含一个完整的示例。
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.