Merge XPS files | Aspose.Page for Java

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

Aspose.Page Java XPS merger allows to merge XPS files to XPS document on any OS for which Java Virtual Machine exists.
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 to PDF document in Java:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir();
 4// Load the first XPS file in a document
 5XpsDocument document = new XpsDocument(dataDir + "input.xps");
 6
 7// Create an array of XPS files that will be merged with the first one
 8String[] filesForMerge = new String[] { dataDir + "Demo.xps", dataDir + "sample.xps" };
 9
10//merge and save to output XPS file
11document.merge(filesForMerge, dataDir + "mergedXPSfiles.xps");

See XPS merge in .NET and C++.

Aspose.Page Java XPS merger allows also 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 Java:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir();
 4
 5// Load the first XPS file in a document
 6XpsDocument document = new XpsDocument(dataDir + "input.xps");
 7
 8// Create an array of XPS files that will be merged with the first one
 9String[] filesForMerge = new String[] { dataDir + "Demo.xps", dataDir + "sample.xps" };
10
11// Initialize options object with necessary parameters.
12com.aspose.xps.rendering.PdfSaveOptions options = new com.aspose.xps.rendering.PdfSaveOptions();
13options.setJpegQualityLevel(100);
14options.setImageCompression(com.aspose.xps.rendering.PdfImageCompression.Jpeg);
15options.setTextCompression(com.aspose.xps.rendering.PdfTextCompression.Flate);
16options.setPageNumbers(new int[] { 1, 2, 6 });
17
18document.mergeToPdf(filesForMerge, dataDir + "XPStoPDF.pdf", options);

See XPS merge in .NET and C++.

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

Evaluate XPS merging online on our XPS Meger.

You can download examples and data files from GitHub.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.