Last active
February 20, 2020 02:27
-
-
Save aspose-com-gists/e4fd3d0d9a5efcbf9a85647f8b0e1740 to your computer and use it in GitHub Desktop.
Word to PDF in 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 the Word document from disk | |
Document doc = new Document("word.docx"); | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// Convert 3 pages starting from index 1 where 0 is the first page's index | |
options.setPageIndex(1); | |
options.setPageCount(3); | |
// Save Word as PDF | |
doc.save("output.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 the Word document from disk | |
Document doc = new Document("word.docx"); | |
// Set PDFSaveOption compliance to PDF15 | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setCompliance(PdfCompliance.PDF_15); | |
// Convert Word to PDF | |
doc.save("output.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 the Word document from disk | |
Document doc = new Document("word.docx"); | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// Text and image compression | |
options.setTextCompression(PdfTextCompression.FLATE); | |
options.setImageCompression(PdfImageCompression.AUTO); | |
// Save Word as PDF | |
doc.save("output.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 the Word document from disk | |
Document doc = new Document("word.docx"); | |
// Set Jpeg quality | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQuality(100); | |
// Convert Word to PDF | |
doc.save("output.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 the Word document from disk | |
Document doc = new Document("word.docx"); | |
// Save as PDF | |
doc.save("output.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment