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
- Merge XPS file to XPS Format Programmatically in C#
- Merge XPS files Programmatically in C#
- Merge XPS files with Advanced Options 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 to XPS Format Programmatically in C#
You can merge different XPS files into a single XPS document with the following steps:
- Load the input XPS file.
- Specify the other XPS files that you want to combine.
- Append the files together into one XPS file.
The code snippet below merges several XPS files into a single XPS document in C#:
Merge XPS files Programmatically in C#
You can merge several XPS files into a single file by following the steps below:
- Load an XPS file to append other files with it.
- Create a rendering device for the output file.
- Create an array of the XPS files to be merged.
- 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:
- Load an input XPS file to merge files.
- Initialize PdfSaveOptions class object.
- Create a rendering device and an array to merge files.
- 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.
Please try the XPS Merging web app to check the file combining capabilities.
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.