使用 DocumentViewer 控件时如何设置打印作业的名称?
我使用 WPF DocumentViewer 控件来显示 XPS 文档,如下所示:
viewer.Document = xpsDocument.GetFixedDocumentSequence();
单击文档查看器内的打印按钮时,所有内容都可以正常打印,但是打印作业的名称是 System.Windows.Documents.FixedDocumentSequence,它小于理想的。
如何设置打印作业的名称?
我知道使用 PrintDialog.PrintDocument() 可以让我设置名称,但我不知道如何使用 DocumentViewer 控件来设置名称。
I've using the WPF DocumentViewer control to display an XPS Document like so:
viewer.Document = xpsDocument.GetFixedDocumentSequence();
When the print button inside the document viewer is clicked everything prints okay, however the name of the print job is System.Windows.Documents.FixedDocumentSequence, which is less than ideal.
How do I set the name of the print job?
I know using PrintDialog.PrintDocument() lets me set the name, but I can't see how to do it using the DocumentViewer control.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案。
将其添加到 XAML
并将其添加到背后的代码中
有几件事值得注意。 如果未绑定 Exectued 事件,则 PreviewExecuted 方法不会发生。 不知道为什么。
I found a solution.
Add this to the XAML
And this to the code behind
A couple of things of note. The PreviewExecuted method doesn't happen if the Exectued event isn't bound to. Don't know why.
我遇到了同样的问题,但是覆盖打印命令在我的情况下不起作用,所以我找到了另一种同样有效的解决方法
I had the same issue however overriding the Print command wouldn't work in my situation so i found another work around that works equally well