This short tutorial guides on how to insert draft watermark in PowerPoint presentation using Java. It is a very common requirement to add draft watermark in presentation in Java such that a particular text is displayed in the background of the slide to show some formatted message mostly rotated by some angle. You can perform this operation on any file format supported by PowerPoint like PPTX.
Steps to Add Draft Watermark in PowerPoint Presentation using Java
- Install Aspose.Slides from the Maven repository to add draft watermark in presentation
- Instantiate a Presentation class object to load the target file
- Prepare a shape to place the draft watermark text
- Set the rotation angle of the shape for displaying rotated text
- Set watermark text in the shape
- Apply formatting to the watermark text in the shape
- Apply locks to the shape to restrict editing in PowerPoint
- Save presentation after adding the draft text as a watermark
These steps guide us to load an existing PowerPoint presentation where first a shape is to be added which will act as a container for the draft text. We set the rotation angle of this shape and also format the text. Finally, we save the output presentation file having a draft watermark in it.
Code to Add Draft Watermark in Presentation using Java
This sample code can be used to add draft watermark in PowerPoint presentation using Java without MS PowerPoint or Interop being installed on the system. It demonstrates this process in a step-by-step approach where first we load the presentation file and then add a text frame having formatted text in the rotated shape. This shape is locked before saving the file on the disc.
In this tutorial, we have learned how to add draft watermark in PowerPoint using Java. For performing other operations on the presentations like converting a presentation to some other format, refer to the article on how to convert PPTX to SVG using Java.