Merge XPS files | Aspose.Page for C++

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

Aspose.Page C++ XPS merger allows to merge XPS files to XPS document on Windows and Linux.
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 (by Merge) XPS files with created document and save it.


Following code snippet shows how to merge XPS files in C++:

 1    // The path to the documents directory.
 2    System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentMerging();
 3    
 4    // Load XPS document from XPS file
 5    System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>());
 6    
 7    // Create an array of XPS files that will be merged with the first one
 8    System::ArrayPtr<System::String> filesToMerge = System::MakeArray<System::String>({dataDir + u"Demo.xps", dataDir + u"sample.xps"});
 9    
10    // Merge XPS files to output XPS document
11    document->Merge(filesToMerge, dataDir + u"mergedXPSfiles.xps");

See XPS merge in .Net and Java.

Aspose.Page C++ XPS merger allows also to merge XPS files into PDF document on Windows and Linux.
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 (by MergeToPdf) 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 C++:

 1//For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-C
 2    // The path to the documents directory.
 3    System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentMerging();
 4    
 5    // Load XPS document form the XPS file
 6    System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>());
 7    
 8    // Initialize options object with necessary parameters.
 9    System::SharedPtr<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions> options = System::MakeObject<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions>();
10    options->set_JpegQualityLevel(100);
11    options->set_ImageCompression(Aspose::Page::XPS::Presentation::Pdf::PdfImageCompression::Jpeg);
12    options->set_TextCompression(Aspose::Page::XPS::Presentation::Pdf::PdfTextCompression::Flate);
13    
14    // Create an array of XPS files that will be merged with the first one
15    System::ArrayPtr<System::String> filesToMerge = System::MakeArray<System::String>({dataDir + u"Demo.xps", dataDir + u"sample.xps"});
16    
17    // Merge XPS files to output PDF file
18    document->MergeToPdf(filesToMerge, dataDir + u"mergedXPSfiles.pdf", options);

See XPS merge in .Net and Java.

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 Merger.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.