在不使用 WindowsFormsHost 的情况下在 WPF 中查看 PDF
是否有用于显示 PDF 的本机 WPF 控件?我正在编写一个程序,该程序将加载 PDF 文件,然后在其顶部显示额外的注释。
使用 WindowsFormsHost (http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/) 将不起作用,因为 WindowsFormsHost 控件始终显示在所有其他控件之上窗口中的 WPF 控件。这不会让我的注释在 PDF 上被看到。
将 PDF 转换为具有我需要的缩放细节级别的光栅图像会创建一个太大的文件。
WebBrowser 控件不允许以编程方式更改或缩放页面。我也无法删除 Adobe 工具栏。
我使用的任何第三方库都需要免费(例如啤酒)。
Are there any native WPF controls for displaying PDFs? I am writing a program that will load a PDF file and then display extra notations on top of it.
Using a WindowsFormsHost (http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/) won't work because a WindowsFormsHost control always displays on top of all other WPF controls in a window. This won't allow my notations to be seen over the PDF.
Converting the PDF into a raster image with the level of zoom detail that I need would create a file that is too large.
The WebBrowser control doesn't allow the pages to be changed or zoomed programmatically. I also can't remove the Adobe toolbars.
Any third-party libraries I used would need to be free (as in beer).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
前提是您的计算机上有一些适用于 IE 的 PDF 查看器插件(例如 Acrobat Reader)...
工作得很好...
Provided that you have some PDF viewer plugin (such as Acrobat Reader) for IE on your machine...
works just fine...
不幸的是,我还没有足够的声誉来发表评论,所以我将其作为答案。
我最近在 Flash 方面遇到了非常类似的问题,最终我使用了 WindowsFormsHost 和 Overlays /装饰者。只是我的2分钱。
下面是 XAML 创建一个覆盖层作为弹出窗口:
为了简单起见,我将覆盖层缩小为一个椭圆形。 Web 浏览器托管在 WindowsFormsHost 中。
这是放置并显示它的代码:
非常简单,但是如果仍有不清楚的地方,请随时询问。
Unfortunately I don't have enough reputations yet to make a comment, so I will put it as an answer.
I have had a very similar problem with Flash recently and I ended up using WindowsFormsHost and Overlays/Adorners. Just my 2cents.
Here is XAML creating an overlay as a popup window:
For the simplicity sake I reduced my overlay to one ellipse. Web Browser is hosted in WindowsFormsHost.
Here is the code placing and showing it:
Pretty simple, however don't hesitate to ask if something is still unclear.
我还没有找到任何运行良好的免版税第三方 WPF 控件。 Telerik 有一个 pdf 查看器,但它不能处理所有类型,也不能很好地处理大型文档。我也尝试过 Syncfusion,但也有问题。我最终将 WindowsFormsHost 与另一个第 3 方 GD 图片的 Windows 窗体查看器一起使用。不过他们说他们正在制作 WPF 版本。
现在还有其他的,你必须为每一个可能很好的服务器安装付费,但我只是无法使用它。
I haven't found any good royalty free 3rd party WPF controls that work well. Telerik has a pdf viewer, but it doesn't do all types and won't do large documents well for me. I tried Syncfusion's as well and that was buggy too. I ended up using WindowsFormsHost with a another 3rd party GD picture's windows forms viewer. They say they're making a WPF version though.
Now there are others that you have to pay for every server install that might be good, I just can't work with that though.