Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created August 11, 2022 07:06

Revisions

  1. aspose-com-gists created this gist Aug 11, 2022.
    11 changes: 11 additions & 0 deletions protected-word-to-json.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # 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)
    1 change: 1 addition & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Read the complete article on how to convert Word to JSON in Python: https://blog.aspose.com
    11 changes: 11 additions & 0 deletions word-to-json.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # 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)