How to Convert XPS to PDF in C#

This article is written to explain how to convert XPS to PDF in C#. It includes the step-wise procedure as well as a runnable sample code to change XPS to PDF in C#. You can load the source XPS file and export it as a PDF file with a few lines of code.

Steps to Convert XPS to PDF using C#

  1. Configure the environment by installing Aspose.Page to convert XPS files
  2. Load the input XPS file using a Stream class object
  3. Initialize a PdfSaveOptions class object and set the necessary parameters
  4. Create a rendering device for output PDF format
  5. Save the output PDF file after converting the XPS file

These steps precisely summarize the process to convert XPS file to PDF in C#. Use the Stream class object to load the input XPS file and then specify different properties for the output PDF document like the image or text compression, etc. Subsequently, create a rendering device like PdfDevice and export the output PDF file.

Code to Convert XPS to PDF in C#

This sample code can be used to convert XPS document to PDF in C#. Moreover, you can change the value of any property like the quality of images, page numbers that you need to convert to PDF format, encryption details, etc. as per your requirements. Similarly, you can read and write the files using the file streams or memory streams with simple API calls.

This tutorial has provided the details pertaining to the conversion of XPS file to PDF in C#. If you want to learn EPS to TIFF conversion, read the article on how to convert EPS to TIFF in C#.