protect method

On this page

protect

Protects the document from changes and sets a protection password.

To have the content of the document editable, use the appropriate method of adding a watermark with WordProcessingLockType.allow_only_form_fields or WordProcessingLockType.read_only_with_editable_content parameter.

def protect(self, protection_type, password):
    ...
Parameter Type Description
protection_type WordProcessingProtectionType Specifies the protection type for the document.
password str The password to protect the document with.

Example

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")

See Also

On this page