Add Watermark to PowerPoint PPT in Python

Watermarks are commonly used to protect a document or to specify its ownership. On the other hand, they are used to display the status of a document such as manuscript, draft, etc. In this article, we will demonstrate how to insert watermarks in PowerPoint presentations. You will learn how to add text or image watermark to PowerPoint PPT slides in Python.

Python Library to Add Watermark to PowerPoint Slides

To add or remove watermarks in PPT slides, we will use Aspose.Slides for Python via .NET. The library enables you to create and manipulate PowerPoint presentations seamlessly from within Python applications. Use the following pip command to install the library from PyPI.

> pip install aspose.slides

Add Watermark to PowerPoint PPT Slides in Python

There are two types of watermark that can be added to PowerPoint slides: image and text. In image-based watermarking, an image is added to the PPT slides. Whereas, a text fragment is placed on the slides in case of text-based watermarking. The following sections explicitly cover both types of watermark.

Add Text Watermark to PowerPoint Slides in Python

The following are the steps to add a text watermark to the PPT slides in Python.

  • First, load the PowerPoint PPT/PPTX using the Presentation class.
  • Get reference of the slide to which you want to add the watermark.
  • Calculate the position of the watermark.
  • Add a new auto shape for watermark using add_auto_shape() method.
  • Add text frame to the shape using add_text_frame() method.
  • Set font size, color, order and rotation angle of the watermark.
  • Lock watermark to avoid removal or modification.
  • Finally, save the updated PowerPoint file using Presentation.save(string, SaveFormat) method.

The following code sample shows how to add a text watermark to the PowerPoint slides.

To add the watermark to all the slides, you can either loop through the slides or add the watermark to the master slide, as shown in the following code sample.

The following is the screenshot of the PowerPoint slide after adding the watermark.

Add Text Watermark to PowerPoint Slides in Python

Add Image Watermark to PowerPoint Slides in Python

The following are the steps to add an image watermark to the PowerPoint slides in Python.

  • First, load the PowerPoint presentation using the Presentation class.
  • Get reference of the slide to which you want to add the watermark.
  • Calculate the position of the watermark.
  • Load the watermark image from file.
  • Add a new shape for watermark using add_auto_shape() method and set shape.fill_format.fill_type to FillType.PICTURE.
  • Set watermark image using shape.fill_format.picture_fill_format.picture.image property.
  • Set order of watermark and lock it to avoid modification.
  • Finally, save the updated PPT using Presentation.save(string, SaveFormat) method.

The following code sample shows how to add an image watermark to PowerPoint slides.

The following is the screenshot of the PPT slide after adding an image watermark.

Add Image Watermark to PowerPoint Slides in Python

Remove Watermark from PPT Slides in Python

In the previous sections, you must have noticed that we have assigned a name to the watermark shapes. This name is used to filter the shapes that are used as a watermark. Thus, we can access, modify or remove the watermark shapes easily. The following code sample shows how to remove the watermarks that we have added to PPT slides in Python.

Get a Free License

You can use Aspose.Slides for Python via .NET without evaluation limitations by requesting a temporary license.

Conclusion

In this article, you have learned how to add a watermark to the PowerPoint slides in Python. We have covered how to add text and image watermarks to PPT slides. Moreover, you have seen how to remove watermark from a PowerPoint PPT programmatically. In addition, you can read the documentation to explore other features of Aspose.Slides for Python. Also, you can post your queries to our forum.

See Also

Info: You may want to check out the free online tools offered by Aspose.Slides to add watermarks and remove watermarks from PowerPoint presentations.