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
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.watermarksimportTextWatermark,Font,Colorfromgroupdocs.watermark.commonimportHorizontalAlignment,VerticalAlignmentfromgroupdocs.watermark.options.diagramimportDiagramShapeWatermarkOptionsfromgroupdocs.watermark.contents.diagramimportDiagramWatermarkPlacementTypedefadd_watermark_to_diagram():withWatermarker("./diagram.vsdx")aswatermarker:watermark=TextWatermark("CONFIDENTIAL",Font("Arial",19.0))watermark.foreground_color=Color.redwatermark.horizontal_alignment=HorizontalAlignment.CENTERwatermark.vertical_alignment=VerticalAlignment.CENTER# Place the watermark on the background of every pageoptions=DiagramShapeWatermarkOptions()options.placement_type=DiagramWatermarkPlacementType.BACKGROUND_PAGESwatermarker.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.
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.