Learn how to convert Word DOCX/DOC to PDF using Python: https://blog.aspose.com/2021/10/27/convert-word-to-pdf-in-python/
Last active
October 27, 2021 15:59
-
-
Save aspose-com-gists/55ed600cecd8b9a8a882e398b2682851 to your computer and use it in GitHub Desktop.
Convert Word DOCX/DOC to PDF in Python
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
import aspose.words as aw | |
# Load word document | |
doc = aw.Document("calibre.docx") | |
# Create save options and set compliance | |
saveOptions = aw.saving.PdfSaveOptions() | |
saveOptions.compliance = aw.saving.PdfCompliance.PDF17 | |
# Save as PDF | |
doc.save("PDF.pdf", saveOptions) |
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
import aspose.words as aw | |
# Load word document | |
doc = aw.Document("calibre.docx") | |
# Create save options and set image compression | |
saveOptions = aw.saving.PdfSaveOptions() | |
saveOptions.image_compression = aw.saving.PdfImageCompression.JPEG | |
saveOptions.jpeg_quality = 100 # Use JPEG compression at 50% quality to reduce file size. | |
# Save as PDF | |
doc.save("PDF.pdf", saveOptions) |
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
import aspose.words as aw | |
# Load word document | |
doc = aw.Document("calibre.docx") | |
# Create save options and set page range | |
saveOptions = aw.saving.PdfSaveOptions() | |
saveOptions.page_set = aw.saving.PageSet([0, 1]) | |
# Save as PDF | |
doc.save("PDF.pdf", saveOptions) |
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
import aspose.words as aw | |
# Load word document | |
doc = aw.Document("calibre.docx") | |
# Save as PDF | |
doc.save("PDF.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment