Learn how to protect Word documents using Python: https://blog.aspose.com/2021/11/15/protect-word-documents-using-python/
Last active
November 16, 2021 15:37
-
-
Save aspose-com-gists/56efcbfae80a8c8a93d11d9946aea2b6 to your computer and use it in GitHub Desktop.
Protect Word Documents using 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 document | |
doc = aw.Document("document1.docx") | |
# create document options | |
options = aw.saving.OoxmlSaveOptions(aw.SaveFormat.DOCX) | |
# set password | |
options.password = "password" | |
# save updated document | |
doc.save("document-password-protected.docx", 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
import aspose.words as aw | |
# load document | |
doc = aw.Document("document1.docx") | |
# apply document protection | |
doc.protect(aw.ProtectionType.READ_ONLY, "password") | |
# save updated document | |
doc.save("document-protected.docx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment