Locking watermark in word processing document

To make a watermark harder to remove, you can lock it by setting is_locked and a lock_type on the watermark option (WordProcessingWatermarkSectionOptions or WordProcessingWatermarkPagesOptions). An optional password is also supported.

Add a locked watermark

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font, Color
from groupdocs.watermark.options.word_processing import (
    WordProcessingLoadOptions, WordProcessingWatermarkSectionOptions, WordProcessingLockType,
)

def add_locked_watermark():
    with Watermarker("./document.docx", WordProcessingLoadOptions()) as watermarker:
        watermark = TextWatermark("CONFIDENTIAL", Font("Arial", 19.0))
        watermark.foreground_color = Color.red

        options = WordProcessingWatermarkSectionOptions()
        options.is_locked = True
        options.lock_type = WordProcessingLockType.ALLOW_ONLY_FORM_FIELDS
        # options.password = "p@ssw0rd"   # optional
        watermarker.add(watermark, options)

        watermarker.save("./output.docx")

if __name__ == "__main__":
    add_locked_watermark()

document.docx is the sample file used in this example. Click here to download it.

Binary file (DOCX, 125 KB)

Download full output

Available WordProcessingLockType values: ALLOW_ONLY_FORM_FIELDS, ALLOW_ONLY_COMMENTS, ALLOW_ONLY_REVISIONS, READ_ONLY, READ_ONLY_WITH_EDITABLE_CONTENT, and NO_LOCK.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.