Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/e3b0360570df476c4cc996cf3211ca24 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/e3b0360570df476c4cc996cf3211ca24 to your computer and use it in GitHub Desktop.
Merge XPS with Java

Merge XPS Examples

These code snippets show how to merge multiple XPS documents into a single XPS package or PDF document using Aspose.Page for Java. This is ideal for consolidating digital documents or preparing files for distribution.

Key Use Cases

  • Merge several XPS documents into one XPS file.
  • Merge several XPS documents into one PDF document.

How to Run Examples

  1. Reference Aspose.Page for Java in your project.
  2. Copy the required code snippet into your project.
  3. Download a temporary license and set it up as described here or use a paid license.
  4. Run the example.

Restrictions

In evaluation mode, total number of pages of merged XPS files is limited to 4. Apply a valid license to use full functionality.

Related Documentation

See Merge XPS Files in the official documentation for more details.

Related Resources

Requirements

  • Java 8 or higher
  • Aspose.Page for Java library
Aspose.Page for Java – Merge XPS Examples
// Merge several XPS files to one PDF document.
// Learn more: https://docs.aspose.com/page/java/merge/xps/
// Load XPS document from the XPS file
XpsDocument document = new XpsDocument(getDataDir() + "input.xps");
// Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions();
options.setJpegQualityLevel(100);
options.setImageCompression(PdfImageCompression.Jpeg);
options.setTextCompression(PdfTextCompression.Flate);
// Create an array of XPS files that will be merged with the first one
String[] filesToMerge = new String[] { getDataDir() + "Demo.xps", getDataDir() + "sample.xps" };
// Merge XPS files to output PDF file
document.mergeToPdf(getOutputDir() + "mergedXPSfiles.pdf", filesToMerge, options);
// Merge several XPS files to one XPS document.
// Learn more: https://docs.aspose.com/page/java/merge/xps/
// Load XPS document from XPS file
XpsDocument document = new XpsDocument(getDataDir() + "input.xps");
// Create an array of XPS files that will be merged with the first one
String[] filesToMerge = new String[] { getDataDir() + "Demo.xps", getDataDir() + "sample.xps" };
// Merge XPS files to output XPS document
document.merge(filesToMerge, getOutputDir() + "mergedXPSfiles.xps");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment