Merge XPS files | .NET API Solution

You can check the quality of Aspose.Page XPS merger and view the results via free online XPS Merger

Aspose.Page .NET XPS Merge allows to merge XPS files to XPS document with using of any language supported by .NET platform: C#, VB, J#.
It is necessary to do several steps in order to perform XPS merge:

  1. Create an instance of XpsDocument from the first XPS file.
  2. Create an array of XPS files that will be merged with the first one.
  3. Merge XPS files with created document and save it.


Following code snippet shows how to merge XPS files in C#:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Load XPS document from XPS file
 5XpsDocument document = new XpsDocument(dataDir + "input1.xps", new XpsLoadOptions());
 6
 7// Create an array of XPS files that will be merged with the first one
 8string[] filesToMerge = new string[] { dataDir + "input2.xps", dataDir + "input3.xps" };
 9
10// Merge XPS files to output XPS document
11document.Merge(filesToMerge, dataDir + "mergedXPSfiles.xps");

See XPS merge in Java and C++.

Aspose.Page .NET XPS Merge also allows to merge XPS files to PDF document.
It is necessary to do several steps in order to perform XPS to PDF merge:

  1. Create an instance of XpsDocument from the first XPS file.
  2. Create an array of XPS files that will be merged with the first one.
  3. Specify TextCompressionImageCompressionJpegQualityLevel, and other options of PdfSaveOptions.
  4. Merge XPS files with created document and save it as PDF with PDF save options.


Following code snippet shows how to merge XPS files to PDF document in C#:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Load XPS document form the XPS file
 5XpsDocument document = new XpsDocument(dataDir + "input1.xps", new XpsLoadOptions());
 6
 7// Initialize options object with necessary parameters.
 8Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions()
 9{
10    JpegQualityLevel = 100,
11    ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg,
12    TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate
13};
14
15// Create an array of XPS files that will be merged with the first one
16string[] filesToMerge = new string[] { dataDir + "input2.xps", dataDir + "input3.xps" };
17
18// Merge XPS files to output PDF file
19document.MergeToPdf(dataDir + "mergedXPSfiles.pdf", filesToMerge, options);

See XPS merge in Java and C++.

Let’s consider PdfSaveOptions. Using this class we can assign different conversion parameters while merging XPS files to PDF.

Evaluate XPS merging online on our XPS Merger.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.