WPF DocumentViewer - 无需确认即可打印
我有一个 WPF 应用程序,我在其中使用文档查看器。我还开始使用 documentviewer.Print(); 以编程方式打印然而,当按下该按钮时,它会显示带有 Windows 打印机的屏幕,并且用户必须在该屏幕上再次单击“确定”才能启动。有没有办法避免确认并进行 documentviewer.Print();立即在默认 Windows 打印机上启动打印作业?
I have a WPF application where I use a document viewer. I also start printing programmatically with documentviewer.Print(); However, when that is pressed it brings up the screen with the Windows printers and makes the user have to click "OK" again on that screen to start. Is there a way to avoid the confirmation and make documentviewer.Print(); immediately start the print job on the default Windows printer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所需要的只是默认的打印队列,您可以通过
此获得它,您可以创建一个 XpsDocumentWriter:
现在,您可以获得 DocumentPaginator 从您的 DocumentViewer 通过 Document 属性,它返回一个 IDocumentPaginatorSource,其具有 DocumentPaginator 属性:
您可以将该权限发送到 XpsDocumentWriter的Write方法:
很简单吧?
All you need is the default print queue, which you can get via
From this, you can create an XpsDocumentWriter:
Now, you can get the DocumentPaginator from your DocumentViewer via the Document property, which returns an IDocumentPaginatorSource that has a DocumentPaginator property:
and you can send that right to the XpsDocumentWriter's Write method:
Simple, isn't it?