Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created August 11, 2022 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/86b958527aa90c096b44a7788b088607 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/86b958527aa90c096b44a7788b088607 to your computer and use it in GitHub Desktop.
Convert Word to JSON in Python
# Load protected document using LoadOptions
doc = aw.Document("protected_doc.docx", aw.loading.LoadOptions("MyPassword"))
# Save document in HTML format
doc.save("html_output.html", aw.SaveFormat.HTML)
# Load the HTML file in an instance of Workbook class
book = Workbook("html_output.html")
# Save as JSON
book.save("word-to-json.json", SaveFormat.JSON)
# Load document
doc = aw.Document("document1.docx")
# Save document in HTML format
doc.save("html_output.html", aw.SaveFormat.HTML)
# Load the HTML file in an instance of Workbook class
book = Workbook("html_output.html")
# Save as JSON
book.save("word-to-json.json", SaveFormat.JSON)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment