WPF打印流程文档
问候, 我在 WPF 中打印时遇到问题。 我正在创建一个流程文档并向该流程文档添加一些控件。 打印预览工作正常,我从打印预览窗口打印没有问题。 当我直接打印到打印机而不进行打印预览时,会出现此问题。但更令人惊讶的是 - 当我使用 XPS Document Writer 作为打印机时 一切正常,当我使用某些物理打印机时,我的流程文档上的某些控件不显示。 提前致谢
Greetings,
I have a problem with printing in WPF.
I am creating a flow document and add some controls to that flow document.
Print Preview works ok and i have no problem with printing from a print preview window.
The problem exists when I print directly to the printer without a print preview. But what is more surprisingly - when I use XPS Document Writer as a printer
everyting is ok, when i use some physical printer, some controls on my flow document are not displayed.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
需要注意的重要事项:即使直接打印到物理打印机,您也可以使用 XpsDocumentWriter。不要犯我所犯的错误,仅仅因为您没有创建 .xps 文件就避免了它!
无论如何 - 我也遇到了同样的问题,并且没有任何
DoEvents()
hacks似乎有效。我对于一开始就必须使用它们也不是特别高兴。在我的情况下,一些数据绑定控件打印得很好,但其他一些(嵌套用户控件)却没有。就好像只有一个“级别”正在进行数据绑定,其余的即使使用“DoEvents()”黑客也不会绑定。解决方案很简单。像这样使用 XpsDocumentWriter。它将打开一个对话框,您可以在其中选择您想要安装的物理打印机。
我发现 OReilly 的关于 'Programming WPF' 的书非常有用,其中的章节打印 - 通过 Google 图书找到。
如果您不希望出现打印对话框,但希望直接打印到默认打印机,您可以执行以下操作。 (对我来说,该应用程序是在仓库环境中打印装箱单 - 我不希望每次都弹出一个对话框)。
Important thing to note : You can use XpsDocumentWriter even when printing directly to a physical printer. Don't make the mistake I did of avoiding it just because you're not creating an .xps file!
Anyway - I had this same problem, and none of the
DoEvents()
hacks seemed to work. I also wasn't particularly happy about having to use them in the first place. In my situation some of the databound controls printed fine, but some others (nested UserControls) didnt. It was as if only one 'level' was being databound and the rest wouldn't bind even with a 'DoEvents()' hack.The solution was simple though. Use XpsDocumentWriter like this. it will open a dialog where you can choose whichever installed physical printer you want.
I found the OReilly book on 'Programming WPF' quite useful with its chapter on Printing - found through Google Books.
If you don't want a print dialog to appear, but want to print directly to the default printer you can do the following. (For me the application is to print packing slips in a warehouse environment - and I don't want a dialog popping up every time).
XPS文档可以毫无问题地打印
XPS Document can be printed without a problem
我注意到一件事:
提示:没有显示的控件是我正在绑定一些数据的控件,所以结论是绑定不起作用。是否可能是在将文档发送到打印机之前未执行装订?
i have noticed one thing:
tip: the controls that are not displayed are the controls I am binding some data, so the conclusion is that the binding doesn't work. Can it be the case that binding is not executing before sending the document to the printer?