Learn how to convert Word documents to EPUB using Python: https://blog.aspose.com/2021/11/19/convert-word-to-epub-in-python/
Last active
November 19, 2021 06:48
-
-
Save aspose-com-gists/83eb6b2571f10bcb93c803e6bc9af881 to your computer and use it in GitHub Desktop.
Convert Word Documents to EPUB 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 the Word document | |
doc = aw.Document("document.docx") | |
# Create an object for save options | |
saveOptions = aw.saving.HtmlSaveOptions() | |
# Set the desired encoding | |
saveOptions.encoding = "utf-8" | |
# Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB | |
# which allows you to limit the size of each HTML part. This is useful for readers which cannot read | |
# HTML files greater than a certain size e.g 300kb. | |
saveOptions.document_split_criteria = aw.saving.DocumentSplitCriteria.HEADING_PARAGRAPH | |
# Enable export of document properties | |
saveOptions.export_document_properties = True | |
# Specify save format | |
saveOptions.save_format = aw.SaveFormat.EPUB | |
# Convert Word document to EPUB | |
doc.save("word-to-epub.epub", 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 the Word document | |
doc = aw.Document("document.docx") | |
# Convert Word document to EPUB | |
doc.save("word-to-epub.epub") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment