Add Watermark to PowerPoint Java

Watermarks are commonly used to specify the ownership or to prevent unauthorized usage of the documents. On the other hand, they are also used to display the status of a document such as a manuscript, draft, etc. In this article, you will learn how to add text or image watermark to PowerPoint slides programmatically using Java.

Java API to Add Watermark to PowerPoint Slides

For adding watermarks to the PowerPoint slides, we’ll use Aspose.Slides for Java. It is a presentation manipulation API that lets you create and manipulate presentation documents from within the Java applications. You can either download the API or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>21.7</version>
    <classifier>jdk16</classifier>
</dependency>

Add Text Watermark to PowerPoint Slides in Java

The following are the steps to add a text watermark to the PowerPoint slides using Java.

  • First, load the PowerPoint presentation using the Presentation class.
  • Get reference of the slide master in an IMasterSlide object.
  • Calculate the position of the watermark according to the dimensions of presentation.
  • Add a new auto shape to the Shapes collection of the slide and get its reference in IAutoShape object.
  • Add text frame to the shape and set its text using IAutoShape.addTextFrame(string) method.
  • Set font size, color 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.

Output

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

Add Text Watermark To PPT Java

Add Image Watermark to PPT Slides in Java

The following are the steps to add an image watermark to the PPT slides in Java.

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

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

Add Image Watermark To PPT Java

Java Watermarking API for PowerPoint - Get a Free License

You can use Aspose.Slides for Java without evaluation limitations by requesting a temporary license.

Try Online

Try the following online watermarking tool which is developed using Aspose.Slides.

Conclusion

In this article, you have learned how to add a watermark to the PowerPoint slides using Java. The step-by-step guide and code samples have demonstrated how to add text and image watermarks to PowerPoint presentations. Furthermore, you can consult the documentation to explore other features of the API. Also, you can feel free to let us know about your queries via our forum.

See Also