One of the main features of GroupDocs.Watermark is adding image watermarks to documents. You can add watermarks to documents or images from a local path, as well as from a stream. For a full list of supported formats, check Supported document formats.
Add an image watermark
To add an image watermark, follow these steps:
Open the document by passing its path (or a stream) to the Watermarker class.
Create an ImageWatermark from the watermark image file (or a stream).
Position the watermark — for example, set horizontal_alignment, vertical_alignment, and opacity.
Call add() to apply the watermark and save() to write the result.
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.watermarksimportImageWatermarkfromgroupdocs.watermark.commonimportHorizontalAlignment,VerticalAlignmentdefadd_image_watermark():withWatermarker("./sample.docx")aswatermarker:# Build an image watermark from a logo file and center itwatermark=ImageWatermark("./logo.png")watermark.horizontal_alignment=HorizontalAlignment.CENTERwatermark.vertical_alignment=VerticalAlignment.CENTERwatermark.opacity=0.7watermarker.add(watermark)watermarker.save("./output.docx")if__name__=="__main__":add_image_watermark()
sample.docx and logo.png are the sample files used in this example. Download sample.docx and logo.png.
GroupDocs.Watermark offers more capabilities for image watermarks — loading from streams, scaling, tiling, and absolute or relative positioning. See Adding image watermarks in the advanced guide.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.