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 appropriate method of adding 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

import groupdocs.watermark as gw
import groupdocs.watermark.contents.wordprocessing as gwc_wp

load_options = gw.WordProcessingLoadOptions()
with gw.Watermarker("document.docx", load_options) as watermarker:
    content = watermarker.get_content(gwc_wp.WordProcessingContent)
    content.protect(gwc_wp.WordProcessingProtectionType.READ_ONLY, "7654321")
    watermarker.save("document.docx")

See Also

On this page