这篇文章将介绍如何使用Spire.Presentation for Java添加、替换和删除PowerPoint幻灯片中的批注信息。
添加批注
import com.spire.presentation.*;
import java.awt.geom.Point2D;
public class PPTComment {
    public static void main(String[] args) throws Exception{
        //加载PowerPoint文档
        Presentation ppt = new Presentation();
        ppt.loadFromFile("Sample.pptx");
        ICommentAuthor author = ppt.getCommentAuthors().addAuthor("E-iceblue", "comment:");
        //添加批注
        ppt.getSlides().get(0).addComment(author, "第一条批注", new Point2D.Float(30, 12), new java.util.Date());
        ppt.getSlides().get(0).addComment(author, "第二条批注", new Point2D.Float(15, 20), new java.util.Date());
        //保存文档
        ppt.saveToFile("output/result.pptx", FileFormat.PPTX_2010);
        ppt.dispose();
    }
}

替换和删除批注
import com.spire.presentation.*;
public class PPTComment2{
    public static void main(String[] args) throws Exception{
        //加载PowerPoint文档
        Presentation ppt = new Presentation();
        ppt.loadFromFile("output/result.pptx");
        //替换第一条批准
        ppt.getSlides().get(0).getComments()[0].setText("替换新批注");
        //删除第二条批注
        ppt.getSlides().get(1).deleteComment(ppt.getSlides().get(0).getComments()[1]);
        //保存文档
        ppt.saveToFile("output/result2.pptx", FileFormat.PPTX_2010);
        ppt.dispose();
    }
}

    


					



