Add Watermark to PPTX Presentation using Java
Build your own Java apps to insert text or image watermark into PPT, PPTX, or ODP presentation using server-side APIs.
Add Watermark to PPTX Presentation via Java
Using Aspose.Slides for Java, you can add watermark to PPTX presentation. Watermarks are an essential part of any presentation. They are used to protect the content of the presentation from being copied or used without permission. A watermark is a visible or invisible image or text that is placed on top of the presentation. It can be used to identify the owner of the presentation and to prevent unauthorized use. Watermarks can also be used to add a professional touch to the presentation and to make it look more polished.
Add Text Watermark to PPTX using Java
Presentation pres = new Presentation();
try {
IMasterSlide master = pres.getMasters().get_Item(0);
IAutoShape watermarkShape = master.getShapes().addAutoShape(ShapeType.Triangle, 0, 0, 0, 0);
ITextFrame watermarkTextFrame = watermarkShape.addTextFrame("Watermark");
pres.save("watermark.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
Add Image Watermark to PPTX Presentation using Java
Presentation pres = new Presentation();
try {
IPPImage image = pres.getImages().addImage(Files.readAllBytes(Paths.get("watermark.png")));
IMasterSlide master = pres.getMasters().get_Item(0);
IAutoShape watermarkShape = master.getShapes().addAutoShape(ShapeType.Triangle, 0, 0, 100, 100);
watermarkShape.getFillFormat().setFillType(FillType.Picture);
watermarkShape.getFillFormat().getPictureFillFormat().getPicture().setImage(image);
watermarkShape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
pres.save("watermark2.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
How to Add Watermark to PPTX via Java
These are the steps to add text watermark to PPTX files.
Load PPTX with an instance of Presentation
Select the master presentation
Add shape type using AddAutoShape method
Add watermark text using AddTextFrame method
Save result in PPTX format