In this quick tutorial, you will learn how to add image watermark in presentation using Java. It will help you to protect presentation by adding image watermark in Java such that the desired image is loaded from the disc and added at different positions and angles in selected or all slides. In the final step, this updated presentation will be saved as PPTX however it can be saved in any file format supported by MS PowerPoint.
Steps to Add Image Watermark in Presentation using Java
- Install Aspose.Slides from the Maven repository to add watermark in presentation
- Load the PPTX file into the Presentation class object for adding an image watermark
- Load the image to be added as a watermark in the presentation
- Add this image to the presentation images collection
- Iterate through the master slides in the presentation
- Add a picture frame with the watermark image to the shapes collection in each slide
- Set the position and rotation angle of the picture frame
- Save the updated presentation having an image watermark on each slide
In these steps, first the presentation and the image to be added as watermark are loaded. This image is added to the images collection of the presentation that is later used by the shape picture frame for displaying it. You can set the shape position and rotation angle before saving the modified presentation having the watermark.
Code to Insert Image Watermark in Presentation using Java
In this code sample, we set the picture frame position and rotation angle however, you can also set the shape locks to avoid modification in the watermark.
This code snippet can be used to add image watermark in presentation in Java. If you want to perform other operations like converting the presentation to some other format like XPS, refer to the article on how to convert PPTX to XPS using Java.