问题
I did a lot of digging to figure out an easy way to convert an XPS
document into a PDF
. There are many tools that can do this but they are not free. Is there a free alternative?
回答1:
A quick google search led me to this: 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.
You need to reference these 2 dll's: http://www.nathanpjones.com/wp/wp-content/uploads/2013/03/PdfSharpXpsBin.zip
Many thanks to Nathan for sharing this information!
Edit: Nathan work is available as a NuGet package here.
来源:https://stackoverflow.com/questions/29108319/is-ther-any-open-tool-to-convert-xps-to-pdf