wpf WPF转PDF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/123947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:38:40  来源:igfitidea点击:

WPF to PDF

wpfpdfpdf-generation

提问by Nir

I have a WPF application and I want to be able to save the output of the application to a PDF document, the item I want to save can be a Visual a Drawing or a FixedDocument (I can create it as any of those options, and it's easy to convert between them).

我有一个 WPF 应用程序,我希望能够将应用程序的输出保存到 PDF 文档中,我要保存的项目可以是 Visual a Drawing 或 FixedDocument(我可以将其创建为这些选项中的任何一个,并且它们之间很容易转换)。

Is there any library that can convert directly from WPF to PDF (without writing code to walk the visual tree and recreate it using PDF primitives).

是否有任何库可以直接从 WPF 转换为 PDF(无需编写代码来遍历可视化树并使用 PDF 原语重新创建它)。

回答by Jobi Joy

If you got your WPF visual tree rendered in to XPS then try this XPS to PDF converter NIXPS.

如果您将 WPF 可视化树呈现为 XPS,请尝试使用此 XPS 到 PDF 转换器NIXPS

回答by nixps

We have just released a new library that facilitates this: NiPDF v1.0

我们刚刚发布了一个新的库来促进这一点:NiPDF v1.0

Here is a linkto an example on our site that converts WPF to PDF.

这是我们网站上将 WPF 转换为 PDF 的示例的链接

It is a 100% managed .NET assembly, and you don't need to learn an arcane API top be able to use it.

它是一个 100% 托管的 .NET 程序集,您无需学习神秘的 API 即可使用它。

回答by yms

For this sceneario I recommend using XpsDocumentWriterclass to get a XPS document, then converting it to PDF using Amyuni PDF Creator
Disclaimer: I work for Amyuni Technologies

对于这个场景,我建议使用XpsDocumentWriter类来获取 XPS 文档,然后使用Amyuni PDF Creator将其转换为 PDF
免责声明:我为 Amyuni Technologies 工作