问题
I am looking for a free open source .Net based, preferably C#, pdf printer such as CutePDF's Custom PDF Writer with programmatic access that will allow me to save a xps document to a pdf format. I have found many alternatives that are capable of converting xps documents to pdf formats, but they are not open source. I was curious to know if anyone is aware of an open source library that will allow me to accomplish this.
回答1:
For any of you out there attempting to convert XPS to PDF using an open source means, I was able to successfully do so using PDFSharp version 1.31. It successfully upgraded to .NET 4.5 and I included the PdfSharp.Xps project into my solution. Once you include all the references, you only need a single line to link to your XPS file.
XpsConverter.Convert("D:\\Example\\test.xps");
Note: There are also other constructors available but I used the most simplistic one in my example.
Hope this helps!
来源:https://stackoverflow.com/questions/14162392/programmatically-print-to-a-pdf-printer