Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 26, 2025 13:46
Show Gist options
  • Select an option

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

Select an option

Save aspose-com-gists/4f62948143e5f7a4800e8c2196f3653a to your computer and use it in GitHub Desktop.
Merge XPS with .NET

Merge XPS Examples

These snippets show how to merge multiple XPS documents into a single XPS package or PDF document using Aspose.Page for .NET. You can combine pages from different sources, keep or change page order, and build consolidated deliverables.

Key Use Cases

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

How to Run Examples

  1. Reference Aspose.Page for .NET: Aspose.Page on Windows; Aspose.Page.Drawing on non‑Windows.
  2. Copy a snippet into your project.
  3. Apply a temporary license as described in the licensing guide.
  4. Build and run.

Restrictions

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

Related Documentation

See supplementary details about merging XPS files in the tutorial Merge XPS files | .NET API Solution.

Related Resources

Requirements

  • .NET 6.0+, .NET Core, or .NET Framework
  • Aspose.Page for .NET library
Aspose.Page for .NET – Merge XPS Examples
// Merge several XPS files to one PDF document.
// Learn more: https://docs.aspose.com/page/net/merge/xps/
// Load XPS document from the XPS file
XpsDocument document = new XpsDocument(DataDir + "input.xps", new XpsLoadOptions());
// Initialize options object with necessary parameters.
Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions()
{
JpegQualityLevel = 100,
ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg,
TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate
};
// Create an array of XPS files that will be merged with the first one
string[] filesToMerge = new string[] { DataDir + "Demo.xps", DataDir + "sample.xps" };
// Merge XPS files to output PDF file
document.MergeToPdf(filesToMerge, OutputDir + "mergedXPSfiles.pdf", options);
// Merge several XPS files to one XPS document.
// Learn more: https://docs.aspose.com/page/net/merge/xps/
// Load XPS document from XPS file
XpsDocument document = new XpsDocument(DataDir + "input.xps", new XpsLoadOptions());
// Create an array of XPS files that will be merged with the first one
string[] filesToMerge = new string[] { DataDir + "Demo.xps", DataDir + "sample.xps" };
// Merge XPS files to output XPS document
document.Merge(filesToMerge, OutputDir + "mergedXPSfiles.xps");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment