Add, Replace and Delete Comment in PowerPoint in Java

This article demonstrates how to add, replace and delete comments in a PowerPoint document using Spire.Presentation for Java.

Add Comments:

import com.spire.presentation.*;
import java.awt.geom.Point2D;


public class PPTComment {
    public static void main(String[] args) throws Exception{
        //load the sample PowerPoint file
        Presentation ppt = new Presentation();
        ppt.loadFromFile("Sample.pptx");

        ICommentAuthor author = ppt.getCommentAuthors().addAuthor("E-iceblue", "comment:");

        //Add comment
        ppt.getSlides().get(0).addComment(author, "The first comment", new Point2D.Float(48, 9), new java.util.Date());

        ppt.getSlides().get(0).addComment(author, "The second added comment", new Point2D.Float(24, 20), new java.util.Date());

        //Save the document
        ppt.saveToFile("output/result.pptx", FileFormat.PPTX_2010);
        ppt.dispose();
    }
}

Add, Replace and Delete Comment in PowerPoint in Java

Replace and delete the comment:

public class PPTComment2{
    public static void main(String[] args) throws Exception{
        //load the sample PowerPoint file
        Presentation ppt = new Presentation();
        ppt.loadFromFile("output/result.pptx");

        //Replace comment
        ppt.getSlides().get(0).getComments()[0].setText("Replace comment");
        //Delete comment
        ppt.getSlides().get(1).deleteComment(ppt.getSlides().get(0).getComments()[1]);

        //Save the document
        ppt.saveToFile("output/result2.pptx", FileFormat.PPTX_2010);
        ppt.dispose();
    }
}

Add, Replace and Delete Comment in PowerPoint in Java