WPF DocumentViewer 不显示文档

发布于 2024-10-02 08:44:48 字数 602 浏览 7 评论 0原文

我正在使用 DocumentViewer 查看固定文档,但在 2 台计算机(超过 500 台)上,文档查看器不显示文档。

编辑:好的,这不是 WPF 中的错误,DocumentViewer 控件工作得很好,我将保留这个问题不变,以防其他人遇到同样的问题,请参阅我的答案以获取解决方案。

  • 文档查看器使用基于 的自定义 ControlTemplate此 MSDN 示例(主要是为了删除搜索框)

  • 工具栏、滚动条和背景全部显示,但滚动条被禁用,并且内容为空白(背景色)

  • 我确定文档没问题,因为打印了文档有效。

  • 我无法访问这些机器,其中一台运行的是 Vista,看起来像是标准配置,我什至不知道另一台运行的是哪个版本的 Window。

  • 该应用程序面向 .net 3.5

这里有人遇到过类似的问题吗?你知道是什么原因造成的吗?

谢谢。

I'm using a DocumentViewer to view a FixedDocument and on 2 machines (out of over 500) the document viewer does not show the document.

Edit: ok, it's not a bug in WPF and the DocumentViewer control works perfectly, I'm leaving this question unchanged in case someone else hits the same problem, see my answer for the solution.

  • The document viewer is using a custom ControlTemplate based on this MSDN sample (mostly to remove the search box)

  • The toolbar, scrollbar and background all show up but the scrollbar is disabled and the content are is blank (background color)

  • I'm sure the document is ok because printing the document works.

  • I don't have any access to those machines, one of them is running Vista in what looks like a standard configuration, I don't even know what version of Window the other one is running.

  • The application is targeting .net 3.5

Did anyone here ever had a similar problem? do you have any idea what's causing it?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剪不断理还乱 2024-10-09 08:44:48

发生的事情是这样的,我使用 PrintDialog 来获取默认打印机的纸张大小,以便创建固定文档,根据文档和我的所有测试,您可以使用 PrintDialog,而无需实际打开对话框或实际打印任何内容,一切都正常。

但在某些计算机上(可能是由于打印机驱动程序行为不当)这不起作用,因此在这些计算机上返回的纸张尺寸不正确,我实际上不知道尺寸太小或两个大,但它导致代码生成FixDocument 无法通过某些内部健全性检查并生成空文档 - DocumentViewer 控件然后通过不显示任何内容来正确显示。

Here's what happened, I was using PrintDialog to get the default printer's paper size in order to create the FixedDocument, according to the docs and all my tests you can use PrintDialog without actually opening the dialog or actually printing anything and everything works just fine.

But on some computers (probably due to misbehaving printer drivers) this doesn't work, so on those computers the returned paper size was incorrect, I actually don't know it the size was too small or two big but it caused the code generating the FixedDocument to fail some internal sanity check and produce and empty document - that the DocumentViewer control then displayed correctly by showing nothing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文