Watermarks in word processing document

When you add a watermark to a Microsoft Word document, a shape with the appropriate content is placed in the section headers. WordProcessingWatermarkSectionOptions (and WordProcessingWatermarkPagesOptions) let you set the shape’s name and alternative_text, and apply text or image effects through the effects property.

Add an image watermark with effects

The example applies brightness, contrast, and a chroma-key to an image watermark using WordProcessingImageEffects.

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import ImageWatermark, Color
from groupdocs.watermark.options.word_processing import (
    WordProcessingLoadOptions, WordProcessingWatermarkSectionOptions, WordProcessingImageEffects,
)

def add_watermark_with_effects():
    with Watermarker("./document.docx", WordProcessingLoadOptions()) as watermarker:
        with ImageWatermark("./logo.png") as watermark:
            effects = WordProcessingImageEffects()
            effects.brightness = 0.7
            effects.contrast = 0.6
            effects.chroma_key = Color.red

            options = WordProcessingWatermarkSectionOptions()
            options.name = "Shape 1"
            options.alternative_text = "Company logo watermark"
            options.effects = effects
            watermarker.add(watermark, options)

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

if __name__ == "__main__":
    add_watermark_with_effects()

document.docx and logo.png are the sample files used in this example. Download document.docx and logo.png.

Binary file (DOCX, 120 KB)

Download full output

For a text watermark, use WordProcessingTextEffects instead — set its line_format (enabled, color, dash style, line style, and weight) and assign it to options.effects. WordProcessingImageEffects also exposes gray_scale and border_line_format.

To work with shapes already present in a document, see Existing objects in word processing document.

Close
Loading

Analyzing your prompt, please hold on...

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