Apply Watermark to Presentation in Java

For the protection of the documents and presentations from illegal use, we can use watermarking. In this article, we will learn to programmatically apply text and image-based watermarks to the presentations or specific slides of a presentation in Java. In another post, we have discussed applying watermarks to presentations using C#.

The following topics will be covered below:

Java Watermarking API for Presentations

GroupDocs.Watermark provides the Java API for watermarking, which allows adding text and image watermarks to the presentations within your application.

Alongside the presentations, the API supports adding, removing, and extracting watermarks from word-processing documents, spreadsheets, email messages, PDF files, images, and many other formats.

Among presentation file formats, it supports PPT, PPTX, PPS, PPTM, PPSX, and others. From the documentation, you may further check the features and supported file formats.

Download and Configure

You can get the watermarking library from the downloads section. For Maven-based Java applications, just add the following pom.xml configuration. Afterward, you can try watermarking examples of this article as well as many more examples from GitHub. For the details, you may visit the API Reference.

<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-watermark</artifactId>
        <version>21.3</version> 
</dependency>

Add Text Watermark to Presentation Slides in Java

Using the API, you can apply customizations while adding text to presentation slides as a watermark. The following steps show how to apply watermark to presentations within the Java application.

  • Load the presentation using Watermarker.
  • Set watermark text and style using TextWatermark.
  • Set watermark properties like size, location, opacity, rotation, and color.
  • Provide the slide index on which to apply the watermark. (Optional)
  • Add the formatted text watermark using the add method.
  • Save the watermarked presentation by calling the save method.

The following code sample shows how to add a text watermark in PPT or PPTX on all the slides with rotation using Java.

If the slide index is not set, the watermark will be applied to all the slides of the presentation by default. The above code also shows how to mention the slide index. The following is the output with a text watermark on all the slides of the PPTX presentation.

Text Watermark to Presentation Slide

Add Image Watermark to PPT Slides using Java

You can add image watermarks on the presentation files as well with a similar approach. Just use the ImageWatermark class instead of the TextWatermark.

The following steps guide how to add image watermark to presentation slides within your Java applications.

  • Load the presentation file using Watermarker.
  • Load the image, logo, or photo using ImageWatermark. It will be used as an image watermark.
  • Set image watermark properties like rotation, size, opacity, color, and position.
  • Set the slide index on which the watermark will be applied.
  • Add the image watermark to the presentation using add method.
  • Save the presentation with the image watermark using save method.

The following code sample adds an image watermark to the second slide of the PPTX presentation in Java.

The following is the output of the code with an image watermark only on the second slide of the PPT/PPTX.

Image Watermark to Presentation Slide

Get a Free API License

You can get a free temporary license in order to use the API without the evaluation limitations.

Conclusion

To conclude, you have learned how to add watermarks to presentations in Java. To be more precise, we discussed how to insert text watermarks as well as image watermarks in presentations within Java-based applications. You can apply watermarks to all the slides as well as to any specific slide of the presentations.

Learn more about the API using documentation. Examples are available at GitHub. For queries, contact us via the forum.

See Also