You can find more details at: Merge XPS Files Programmatically in Java
Last active
June 28, 2022 09:20
-
-
Save aspose-com-gists/26d821b928f8ca3cac014e4a5c80d714 to your computer and use it in GitHub Desktop.
Merge or Combine XPS Files Programmatically Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PDF output stream | |
FileOutputStream pdfStream = new FileOutputStream("MergeXPS.pdf"); | |
// Load the first XPS document | |
XpsDocument document = new XpsDocument("input.xps"); | |
// Initialize options object with necessary parameters. | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQualityLevel(100); | |
options.setImageCompression(PdfImageCompression.Jpeg); | |
options.setTextCompression(PdfTextCompression.Flate); | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(pdfStream); | |
// Create an array of XPS files that will be merged with the first one | |
String[] filesToMerge = new String[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files to output PDF document | |
document.merge(filesToMerge, device, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize XPS output stream | |
FileOutputStream xpsStream = new FileOutputStream("mergedXPSfiles.xps"); | |
// Load the first XPS document | |
XpsDocument document = new XpsDocument(dataDir + "input.xps"); | |
// Create an array of XPS files that will be merged with the first one | |
var filesToMerge = new String[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files | |
document.merge(filesToMerge, xpsStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PDF output stream | |
FileOutputStream pdfStream = new FileOutputStream("MergeXPS.pdf"); | |
// Load the first XPS document | |
XpsDocument document = new XpsDocument("input.xps"); | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(pdfStream); | |
// Create an array of XPS files that will be merged with the first one | |
String[] filesToMerge = new String[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files to output PDF document | |
document.merge(filesToMerge, device, new PdfSaveOptions()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment