Protecting word processing documents
Leave feedback
On this page
Beyond locking an individual watermark, you can protect the whole document. Watermarker.get_content() returns a WordProcessingContent with protect() and unprotect() methods.
The example sets read-only protection with a password.
from groupdocs.watermark import Watermarker
from groupdocs.watermark.options.word_processing import WordProcessingLoadOptions
from groupdocs.watermark.contents.word_processing import WordProcessingProtectionType
def protect_document():
with Watermarker("./document.docx", WordProcessingLoadOptions()) as watermarker:
content = watermarker.get_content()
content.protect(WordProcessingProtectionType.READ_ONLY, "p@ssw0rd")
watermarker.save("./output.docx")
if __name__ == "__main__":
protect_document()
document.docx is the sample file used in this example. Click here to download it.
Binary file (DOCX, 119 KB)
Available WordProcessingProtectionType values: READ_ONLY, ALLOW_ONLY_FORM_FIELDS, ALLOW_ONLY_COMMENTS, and ALLOW_ONLY_REVISIONS.
from groupdocs.watermark import Watermarker
from groupdocs.watermark.options.word_processing import WordProcessingLoadOptions
def unprotect_document():
with Watermarker("./document.docx", WordProcessingLoadOptions()) as watermarker:
content = watermarker.get_content()
content.unprotect()
watermarker.save("./output.docx")
if __name__ == "__main__":
unprotect_document()
document.docx is the sample file used in this example. Click here to download it.
Binary file (DOCX, 118 KB)
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.