Locking watermark in word processing document

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Watermark MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-watermark -- dnx GroupDocs.Watermark.Mcp --yes
Folders, licensing and more →

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, 240 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.