Merge XPS Files Programmatically in C#

Merge Combine XPS C#

XPS files are based on XML Paper Specifications which represent page layouts. They include information about appearance and printing layouts. Sometimes you might want to merge multiple XPS files for further processing of data. In accordance with such requirements, this article explains how to merge XPS files programmatically in C#.

Combine or Merge XPS files – C# API Installation

Aspose.Page for .NET API is a high code file format API where you only need to make a few API calls. You can access the API by downloading its DLL files from the Downloads section or with the following NuGet installation command:

PM> Install-Package Aspose.Page

Merge XPS files Programmatically in C#

You can merge several XPS files into a single file by following the steps below:

  1. Load an XPS file to append other files with it.
  2. Create a rendering device for the output file.
  3. Create an array of the XPS files to be merged.
  4. Merge the XPS files and save the output in PDF format.

The following code shows how to merge XPS  files and save the output in PDF format programmatically in C#:

Merge XPS files with Advanced Options in C#

You can specify different properties to improvise the XPS merging process. For instance, you can set image or text compression, encryption, privileges, etc. for the output file by following the steps below:

  1. Load an input XPS file to merge files.
  2. Initialize PdfSaveOptions class object.
  3. Create a rendering device and an array to merge files.
  4. Merge the XPS files and save the result as a PDF.

The following code snippet demonstrates how to merge XPS files in C#:

Get Free Temporary License

You can request a free temporary license to evaluate the API without any limitations.

Online Demo

Please try the XPS Merging web app to check the file combining capabilities.

Conclusion

In this article, you have explored how to merge XPS files programmatically in C#. In case you need to discuss any of your queries, please write to us at the forum.

See Also

Convert EPS or PS to SVG in C#