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.
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.watermarksimportImageWatermark,Colorfromgroupdocs.watermark.options.word_processingimport(WordProcessingLoadOptions,WordProcessingWatermarkSectionOptions,WordProcessingImageEffects,)defadd_watermark_with_effects():withWatermarker("./document.docx",WordProcessingLoadOptions())aswatermarker:withImageWatermark("./logo.png")aswatermark:effects=WordProcessingImageEffects()effects.brightness=0.7effects.contrast=0.6effects.chroma_key=Color.redoptions=WordProcessingWatermarkSectionOptions()options.name="Shape 1"options.alternative_text="Company logo watermark"options.effects=effectswatermarker.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.
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.