Converting an XPS Document to PDF

24 Jul 20261 minute to read

The XPS (XML Paper Specification) document format is a fixed-document format that consists of structured XML markup defining the layout of a document and the visual appearance of each page, along with rendering rules for distributing, archiving, rendering, processing, and printing the documents.

The following code example illustrates how to convert an XPS document to PDF using the XPSToPdfConverter class.

//Initialize the XPS to PDF converter.
XPSToPdfConverter converter = new XPSToPdfConverter();
//Convert the XPS to PDF.
PdfDocument document = converter.Convert("Input.xps");

//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
//Create the converter class.
XPSToPdfConverter converter = new XPSToPdfConverter();
//Convert the XPS to a PDF document.
PdfDocument document = converter.Convert(xpsFileName);

//Save and close the document.
document.Save("Sample.pdf");
document.Close(true);
'Create the converter class.
Dim converter As New XPSToPdfConverter()
'Convert the XPS to a PDF document.
Dim document As PdfDocument = converter.Convert(xpsFileName)

'Save and close the document.
document.Save("Sample.pdf")
document.Close(True)

You can download a complete working sample from GitHub.

NOTE

In ASP.NET Core, XPS to PDF conversion requires the Syncfusion.XpsToPdfConverter.Net.Core NuGet package.