Add watermarks to Diagram documents

GroupDocs.Watermark adds watermarks to Visio diagrams as shapes placed on the background or foreground of the pages. Open the diagram and pass a DiagramShapeWatermarkOptions to add() with the desired placement_type.

Note
Open Visio files with format auto-detection — Watermarker("diagram.vsdx") — rather than passing DiagramLoadOptions() to the constructor.

Add a watermark to a diagram

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font, Color
from groupdocs.watermark.common import HorizontalAlignment, VerticalAlignment
from groupdocs.watermark.options.diagram import DiagramShapeWatermarkOptions
from groupdocs.watermark.contents.diagram import DiagramWatermarkPlacementType

def add_watermark_to_diagram():
    with Watermarker("./diagram.vsdx") as watermarker:
        watermark = TextWatermark("CONFIDENTIAL", Font("Arial", 19.0))
        watermark.foreground_color = Color.red
        watermark.horizontal_alignment = HorizontalAlignment.CENTER
        watermark.vertical_alignment = VerticalAlignment.CENTER

        # Place the watermark on the background of every page
        options = DiagramShapeWatermarkOptions()
        options.placement_type = DiagramWatermarkPlacementType.BACKGROUND_PAGES
        watermarker.add(watermark, options)

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

if __name__ == "__main__":
    add_watermark_to_diagram()

diagram.vsdx is the sample file used in this example. Click here to download it.

Binary file (VSDX, 29 KB)

Download full output

Use DiagramWatermarkPlacementType.FOREGROUND_PAGES to place the watermark in front of the page content instead. Watermarker.get_content() returns a DiagramContent exposing each page’s shapes and headers/footers — see Existing objects in diagrams.

Close
Loading

Analyzing your prompt, please hold on...

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