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
- Merge XPS files into XPS using Java
- Merge XPS files Programmatically in Java
- Merge XPS files with Advanced Options 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:
- Load the source XPS document to combine files.
- Specify the paths to other XPS files.
- 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:
- Load an input XPS file to combine other XPS documents.
- Initialize a rendering device to write the output file.
- Declare and initialize an array to hold the input XPS documents.
- 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:
- Load the input XPS file for combining files.
- Create an object of the PdfSaveOptions class.
- Make a rendering device and initialize a string array to store file paths.
- 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.
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.