Convert XPS Files to PDF format in C#

XPS is short for XML Paper Specification developed by Microsoft, which is a specification for a page description language and a fixed-document format. It comes out by Microsoft’s initiative to associate file creation with reading in its Windows operating system. Like PDF, XPS plays a loyal role to preserve document with offering device-independent document appearance. Editing in XPS or in PDF seems difficult.

As a flexible and professional component, Spire.PDF for .NEToffers a large variety conversion, among which the conversion from XPS to PDF is one of its popular feature. In addition, Spire.PDF for .NET can be applied in WinForm, ASP.NET and Console Application.

The following code example shows how to convert XPS files to PDF document.

Step 1: Introduce a class named pdfDocument which is used to initialize a Spire.PDF.PdfDocument, and load a XPS file by calling the method of LoadForm File.

PdfDocument doc = new PdfDocument();

Step 2: Only needs one row of simple code. Call the SavetoFile method of Spire.PDF.pdfDocument to save all the data as PDF formart.

doc.SaveToFile(pdfFile, FileFormat.PDF);

After this code, run this application and you will see the PDF converted from XPS.

Screenshot before converting XPS to PDF:

Screenshot after converting XPS to PDF: