I'm newbie in WPF and I'm trying to print student's exam papers using WPF and I'm creating exam papers using System.Drawing.Graphics
and now I want to print them.
But it seems every printable thing in WPF is somehow a control. I have two problems:
Graphics
Like WinForms PrintDocument
(that has it's own problems)would you help me with any of theses questions?
答案 0 :(得分:2)
您可以利用PrintDocument类,而不是WPF特定的类。此类允许您将输出发送到打印机。应该处理PrintPage事件,您可以使用PrintPageEventArgs获取Graphics上下文;用于将检查绘制到打印机输出。这被认为是Winforms的打印方式。
WPF增强了printing命名空间提供的System.Printing支持。这些打印服务用于管理打印作业,发现打印队列和配置的打印机。 WPF中的打印通常通过生成XPS文档来执行,利用XpsDocumentWriter类&方法。但是,由于使用了System.Drawing.Graphics,因此也可以使用GDI打印,这是您可能需要的。请参阅GDI打印路径部分here。