You can read more details at: Convert XPS or OXPS to Word Document using Java
Last active
March 16, 2022 08:17
-
-
Save aspose-com-gists/57c37387e8fcf4af62b876c2ada169d2 to your computer and use it in GitHub Desktop.
Convert XPS to Word DOCX/DOC in Java | OXPS to Word DOCX DOC Document Programmatically using 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 ByteArrayOutputStream to hold intermediary PDF file | |
final ByteArrayOutputStream os = new ByteArrayOutputStream(); | |
// Load input OXPS document | |
XpsDocument document = new XpsDocument("sample.oxps"); | |
// Initialize PdfSaveOptions object with necessary parameters | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQualityLevel(100); | |
options.setImageCompression(PdfImageCompression.Jpeg); | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(os); | |
// Save output PDF file | |
document.save(device, options); | |
// Load the intermediate PDF file | |
Document pdfDocument = new Document(os.toByteArray()); | |
// Save output Word document as DOCX file | |
pdfDocument.save("output.docx" , SaveFormat.DocX); |
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 ByteArrayOutputStream to hold intermediary PDF file | |
final ByteArrayOutputStream os = new ByteArrayOutputStream(); | |
// Load input XPS document | |
XpsDocument document = new XpsDocument("sample.xps"); | |
// Initialize PdfSaveOptions object with necessary parameters | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQualityLevel(100); | |
options.setImageCompression(PdfImageCompression.Jpeg); | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(os); | |
// Save output PDF file | |
document.save(device, options); | |
// Load the intermediate PDF file | |
Document pdfDocument = new Document(os.toByteArray()); | |
// Save output Word document as DOCX file | |
pdfDocument.save("output.docx" , SaveFormat.DocX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment