Last active
April 21, 2021 12:23
-
-
Save aspose-com-gists/bae36f809fa8c521dc664e0269b29624 to your computer and use it in GitHub Desktop.
Word用Java转换为PDF
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
// 从磁盘加载Word文档 | |
Document doc = new Document("word.docx"); | |
//另存为PDF | |
doc.save("output.pdf"); |
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
// 从磁盘加载Word文档 | |
Document doc = new Document("word.docx"); | |
// 设定Jpeg品质 | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setJpegQuality(100); | |
// 将Word转换为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
// 从磁盘加载Word文档 | |
Document doc = new Document("word.docx"); | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// 文字和图像压缩 | |
options.setTextCompression(PdfTextCompression.FLATE); | |
options.setImageCompression(PdfImageCompression.AUTO); | |
// 将Word另存为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
// 从磁盘加载Word文档 | |
Document doc = new Document("word.docx"); | |
// 将PDFSaveOption符合性设置为PDF15 | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setCompliance(PdfCompliance.PDF_15); | |
// 将Word转换为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
// 从磁盘加载Word文档 | |
Document doc = new Document("word.docx"); | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// 从索引1开始转换3页,其中0是第一页的索引 | |
options.setPageIndex(1); | |
options.setPageCount(3); | |
// 将Word另存为PDF | |
doc.save("output.pdf", options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment