Add Watermark to PPTX Presentation using Java

Build Java applications that insert text or image watermarks into presentation files using server-side APIs.

Add Watermark to PPTX Presentation via Java

Using Aspose.Slides for Java , you can add text and image watermarks to PPTX presentations. Add a watermark shape to a master slide so the watermark appears on slides that use that master.

Add Text Watermark to PPTX using Java

Presentation presentation = new Presentation("presentation.pptx");
try {
    IMasterSlide masterSlide = presentation.getMasters().get_Item(0);
    IAutoShape watermarkShape = masterSlide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 400, 120);
    ITextFrame watermarkTextFrame = watermarkShape.addTextFrame("Watermark");
    watermarkTextFrame.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().setFontHeight(48);

    presentation.save("watermark.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

Add Image Watermark to PPTX Presentation using Java

Presentation presentation = new Presentation("presentation.pptx");
try {
    byte[] imageData = Files.readAllBytes(Paths.get("watermark.png"));
    IPPImage watermarkImage = presentation.getImages().addImage(imageData);
    IMasterSlide masterSlide = presentation.getMasters().get_Item(0);
    IAutoShape watermarkShape = masterSlide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 300, 200);

    watermarkShape.getFillFormat().setFillType(FillType.Picture);
    watermarkShape.getFillFormat().getPictureFillFormat().getPicture().setImage(watermarkImage);
    watermarkShape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);

    presentation.save("image-watermark.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

How to Add Watermark to PPTX via Java

Follow these steps to add a text or image watermark to PPTX files.

  1. Load the PPTX file with the Presentation class.
  2. Select a master slide through the getMasters method.
  3. Call the addAutoShape method to add a watermark shape.
  4. Call the addTextFrame method to add watermark text or use addImage for an image watermark.
  5. Save the watermarked presentation in PPTX format.

Built with Aspose.Slides

Add Watermarks to PPTX Online

The free Aspose.Slides Watermark app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own PPTX files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides adds watermarks before you write code.
  • Add a text or image watermark to your PPTX file.
  • Download the watermarked file.

Other Supported Watermark Formats

Using Java, you can also add watermarks to the following formats.