Merge XPS Java

XPS format consists of XML markup which explains visual representation or rendering rules for a document. In certain cases, you may need to merge or combine many XPS documents. For such use cases, this article covers how to merge XPS files programmatically in Java.

Combine or Merge XPS files – Java API Installation

Aspose.Page for Java API can be used to work with EPS, XPS, and other popular file formats. You can configure the API by downloading its JAR files from the Downloads page or paste the following configurations into the pom.xml file of your project:






Merge XPS files into XPS using Java

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

  1. Load the source XPS document to combine files.
  2. Specify the paths to other XPS files.
  3. Merge the XPS files and save output file in XPS format.

The following code sample demonstrates how to merge several XPS files into an XPS file in Java:

Merge XPS files Programmatically in Java

You can merge different XPS documents into one file with the following steps:

  1. Load an input XPS file to combine other XPS documents.
  2. Initialize a rendering device to write the output file.
  3. Declare and initialize an array to hold the input XPS documents.
  4. Merge the XPS documents and write the output file in PDF format.

The code snippet below elaborates on how to merge different XPS files into one and export the output file as a PDF document programmatically in Java:

Merge XPS files with Advanced Options in Java

You can enhance the XPS merging process by configuring several properties. For example, PDF passwords, permissions, privileges, or compression can be controlled based on your requirements. Please follow the steps below in order to merge XPS files with advanced options:

  1. Load the input XPS file for combining files.
  2. Create an object of the PdfSaveOptions class.
  3. Make a rendering device and initialize a string array to store file paths.
  4. Merge multiple input XPS files and save the output as PDF.

The code sample below explains how to merge XPS files with advanced options in Java:

Get Free Temporary License

You can get a free temporary license in order to test the API at its full capacity.

Online Demo

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


In this article, you have learned how to merge many XPS files together programmatically in Java. However, if you want to discuss your requirements or concerns, please feel free to reach out to us at the forum.

See Also

Convert a Postscript PS or EPS file to PDF using Java