PPTX DOCX XLSX PDF ODP
Aspose.Slides  for Java
PPTX

Add Text Watermark to PPTX in Java

Build your own Java apps to watermark PPTX files using server-side APIs.

Watermark PPTX File Using Java

In order to watermark PPTX file, we’ll use

Aspose.Slides for Java

API which is a feature-rich, powerful and easy to use watermarking API for Java platform. You can download its latest version directly from

Maven

and install it within your Maven-based project by adding the following configurations to the pom.xml.

Repository


<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository>

Dependency


<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>version of aspose-slides API</version>
    <classifier>jdk17</classifier>
</dependency>

How to Add Watermark to PPTX via Java

  1. Load PPTX file using Presentation class

  2. Loop through all slides

  3. Add text using addTextFrame

  4. Set all the relevant options like color, fillType and more

  5. Save the document

System Requirements

Aspose.Slides for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.

 

Add Watermark to PPTX - Java


Presentation pres = new Presentation("TestPres.pptx");

for(ISlide slide:pres.getSlides()){
    IAutoShape ashp = slide.getShapes()
                    .addAutoShape(ShapeType.Rectangle,50, 50, 500, 500);
    ashp.addTextFrame("Watermark Text");

    ashp.getTextFrame().getParagraphs().get_Item(0).getPortions()
                        .get_Item(0).getPortionFormat().getFillFormat()
                        .setFillType(FillType.Solid);
    ashp.getTextFrame().getParagraphs().get_Item(0).getPortions()
                        .get_Item(0).getPortionFormat().getFillFormat()
                        .getSolidFillColor().setColor(Color.GRAY);
    ashp.getTextFrame().getParagraphs().get_Item(0).getPortions()
                        .get_Item(0).getPortionFormat().setFontHeight(25);

    // Change the line color of the rectangle to White
    ashp.getShapeStyle().getLineColor().setColor(Color.WHITE);
    ashp.getShapeStyle().setLineStyleIndex(LineStyle.ThinThin);

    // Remove any fill formatting in the shape
    ashp.getFillFormat().setFillType(FillType.NoFill);

    ashp.setRotation(-45);

    ashp.getAutoShapeLock().setSelectLocked(true);
    ashp.getAutoShapeLock().setSizeLocked(true);
    ashp.getAutoShapeLock().setTextLocked(true);
    ashp.getAutoShapeLock().setPositionLocked(true);
    ashp.getAutoShapeLock().setGroupingLocked(true);
}
  
pres.save(path + "SavedWatermark.pptx", SaveFormat.Pptx);   
 
  • About Aspose.Slides for Java API

    Aspose.Slides API can be used to read, write, manipulate and convert Microsoft PowerPoint documents to PDF, XPS, HTML, TIFF, ODP and various other formats. One can create new files from scratch and save those in the relevant supported formats. Aspose.Slides is a standalone API for creating, parsing or manipulating presentations, slides and elements and it does not depend on any software like Microsoft or OpenOffice.

    Watermark PPTX via Online App

    Other Supported Watermarking Formats

    Using Java, one can easily watermark different formats including.

    PPT (Microsoft PowerPoint 97-2003)