How to Convert XPS to PDF using C#

This article walks you through the stepwise process to convert XPS to PDF using C# by consuming one of the popular document conversion packages. This tutorial also provides a sample application for C# convert XPS to PDF to show the implementation and working of the feature. Further, this post guides you on how to define parameters for customizing the converted PDF file. Below is a list of key points and a sample code to change XPS to PDF in C#.

Steps to Convert XPS to PDF using C#

  1. Install GroupDocs.Conversion for .NET package from the NuGet website to convert XPS to PDF
  2. Add a reference to the GroupDocs.Conversion namespace for converting from XPS to PDF format
  3. Initialize the Converter class for loading the input XPS file from the disk for converting to PDF format
  4. Create and set convert options for customizing the output PDF file
  5. Finally, invoke the Convert method to save XPS as PDF on the disk

To implement the convert XPS to PDF C# functionality, you just need to follow the above workflow. You have to load the input XPS file by instantiating the Converter class after installing the required document conversion package from the NuGet package manager and importing the essential namespaces. After this, you can set properties to customize the converted PDF file using the PdfConvertOptions object and finally call the Convert method for saving the resultant file on the disk.

Code to Convert XPS to PDF using C#

The above snippet demonstrates the implementation of the XPS to PDF converter in C#. This sample code can be easily used in your applications for performing document transformation but you have to first set up the conversion package and supply the license and input files. Moreover, you do not need to install any additional software for using this example and can run this code on any of the popular operating systems such as Windows, Linux, and macOS that support a .NET environment.

We have discussed the document conversion procedure for C# XPS to PDF capability and produced a sample code for it. Recently, we published an article to change EPS to JPG using C#, have a look at how to convert EPS to JPG in C# guide for more information.

 English