Add Watermark to PowerPoint Java

Watermarks are commonly used to specify ownership or to prevent unauthorized usage of 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 PPT programmatically in Java.

Java API to Add Watermark to PowerPoint PPT 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 PPT 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 the 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 the 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 PPT slides in Java.

Output

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

Add Text Watermark To PPT Java

Java Add Image Watermark to PPT Slides

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 PPT slides in Java.

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

Add Image Watermark To PPT Java

Java API to Watermark PPT Slides - Get a Free License

You can use Aspose.Slides for Java without evaluation limitations by getting a free 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 PPT slides in Java. The step-by-step guide and code samples have demonstrated how to add text and image watermarks to PowerPoint presentations.

Java PowerPoint PPT Watermarking API - Read More

You can consult the documentation to explore other features of Aspose.Slides for Java. Also, you can feel free to let us know about your queries via our forum.

See Also