wpf 使用 asp.net 免费将 XPS 转换为 PDF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29108319/
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-13 13:00:54  来源:igfitidea点击:

Convert XPS to PDF for free using asp.net

c#asp.netwpfpdfsharpxps

提问by Bolo

I did a lot of digging to figure out an easy way to convert an XPSdocument into a PDF. There are many tools that can do this but they are not free. Is there a free alternative?

我进行了大量挖掘以找出一种将XPS文档转换为PDF. 有很多工具可以做到这一点,但它们不是免费的。有免费的替代品吗?

回答by Bolo

A quick google search led me to this: http://www.nathanpjones.com/wp/2013/03/output-to-pdf-in-wpf-for-free/

一个快速的谷歌搜索让我找到了这个:http: //www.nathanpjones.com/wp/2013/03/output-to-pdf-in-wpf-for-free/

I was able to get it to work after I trimmed down some of the code I did not need. Here is the result:

在我修剪了一些我不需要的代码后,我能够让它工作。结果如下:

using (PdfSharp.Xps.XpsModel.XpsDocument pdfXpsDoc = PdfSharp.Xps.XpsModel.XpsDocument.Open(xpsPath))
{
    PdfSharp.Xps.XpsConverter.Convert(pdfXpsDoc, pdfPath, 0);
}

The 2 path variables are just strings.

2个路径变量只是字符串。

You need to reference these 2 dll's: http://www.nathanpjones.com/wp/wp-content/uploads/2013/03/PdfSharpXpsBin.zip

您需要引用这 2 个 dll:http: //www.nathanpjones.com/wp/wp-content/uploads/2013/03/PdfSharpXpsBin.zip

Many thanks to Nathan for sharing this information!

非常感谢内森分享这些信息!