Add Watermarks to PPTX Presentations with Python
Build Python applications that add text or image watermarks to PPTX presentations with Aspose.Slides.
Add a Watermark to a PPTX Presentation with Python
With Aspose.Slides for Python via .NET , you can add a text or image watermark to a PPTX presentation without using Microsoft PowerPoint. A watermark can identify ownership, mark a presentation as confidential or a draft, or provide consistent branding. The examples below place the watermark on the first master slide, so it appears on slides that use that master.
Add a Text Watermark to a PPTX Presentation - Python
with slides.Presentation("presentation.pptx") as presentation:
master_slide = presentation.masters[0]
watermark_shape = master_slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 100, 100, 400, 50)
watermark_text_frame = watermark_shape.add_text_frame("CONFIDENTIAL")
watermark_shape.fill_format.fill_type = slides.FillType.NO_FILL
watermark_shape.line_format.fill_format.fill_type = slides.FillType.NO_FILL
watermark_portion = watermark_text_frame.paragraphs[0].portions[0]
watermark_portion.portion_format.font_height = 32
watermark_shape.auto_shape_lock.select_locked = True
watermark_shape.auto_shape_lock.size_locked = True
watermark_shape.auto_shape_lock.text_locked = True
watermark_shape.auto_shape_lock.position_locked = True
watermark_shape.auto_shape_lock.grouping_locked = True
presentation.save("watermarked.pptx", slides.export.SaveFormat.PPTX)Add an Image Watermark to a PPTX Presentation - Python
with slides.Presentation("presentation.pptx") as presentation:
with open("watermark.png", "rb") as image_stream:
watermark_image = presentation.images.add_image(image_stream.read())
master_slide = presentation.masters[0]
watermark_shape = master_slide.shapes.add_auto_shape(
slides.ShapeType.RECTANGLE, 100, 100, watermark_image.width, watermark_image.height)
watermark_shape.fill_format.fill_type = slides.FillType.PICTURE
watermark_shape.fill_format.picture_fill_format.picture.image = watermark_image
watermark_shape.fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.STRETCH
watermark_shape.line_format.fill_format.fill_type = slides.FillType.NO_FILL
presentation.save("watermarked.pptx", slides.export.SaveFormat.PPTX)How to Add a Watermark to PPTX via Python
Follow these steps to add a text watermark to a PPTX presentation.
- Open the PPTX file with
Presentation. - Get the first master slide from the
masterscollection. - Call
add_auto_shapeto add a rectangle to the master slide. - Call
add_text_frameto add the watermark text, then format and lock the shape. - Call
savewithSaveFormat.PPTXto write the watermarked presentation.
Built with Aspose.Slides
Add Watermarks to PPTX Online
The free Aspose.Slides Watermark app is built with Aspose.Slides for Python via .NET, the same API as the code above. Open it and see what the API can do with your own PPTX files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides adds watermarks before you write code.
- Add a text or image watermark to your PPTX file.
- Download the watermarked file.
Other Supported Watermark Formats
Use Python to add watermarks to other supported presentation formats.