Last active
July 4, 2024 13:27
-
-
Save aspose-com-gists/36014fe18885c184d472ae34c0c29750 to your computer and use it in GitHub Desktop.
Convert OXPS or XPS to PDF Programmatically with 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
// Load input OXPS document | |
XpsDocument document = new XpsDocument(dataDir + "input.oxps"); | |
// Initialize options object with necessary parameters | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// Specify page numbers to render | |
options.setPageNumbers(new int[] { 1,3 }); | |
// Save OXPS document to output PDF file | |
document.saveAsPdf(dataDir + "OXPStoPDF.pdf", 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
// Load input XPS document | |
XpsDocument document = new XpsDocument(dataDir + "input.xps"); | |
// Initialize options object with necessary parameters | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQualityLevel(100); | |
options.setImageCompression(PdfImageCompression.Jpeg); | |
options.setTextCompression(PdfTextCompression.Flate); | |
// Save XPS document to output PDF file | |
document.saveAsPdf(dataDir + "XPStoPDF.pdf", options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment