这篇文章将介绍如何使用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();
}
}