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?
For Google Drive users, upload the XPS file to your Drive. Then, double-click the file to open it. Alternatively, try an online XPS-to-PDF file converter to view the content as a PDF.
How to open an XPS file. Windows users can open XPS files in Microsoft XPS Viewer. In Windows 11 and later versions of Windows 10, you must manually install XPS Viewer by going to Settings → Apps → Optional features → Add an optional feature and searching for XPS Viewer.
1 Correct answer. Adobe Acrobat does not support opening of XPS files. It does support creating a new PDF file from an XPS file, although that function is not supported via command line. Adobe Acrobat does not support opening of XPS files.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With