import com.spire.doc.*;
public class ModifyComment {
public static void main(String[] args){
//加载含有批注的测试文档
Document doc = new Document("sample.docx");
//获取第一个批注中的第一段,用文本替换原有批注中的文本
doc.getComments().get(0).getBody().getParagraphs().get(0).replace("请在试验中将包含以下特征的实验样本记录在册,并整理好周记录报表,供后续观察取样。","参照以下实验方法!",false,false);
//获取第一个批注中的第二段,用文本替换原有批注中的图片
doc.getComments().get(0).getBody().getParagraphs().get(1).setText("请上报管理科!");
//获取第一个批注中的第三段,删除原有图片,再调用方法添加新图片(用图片替换图片)
doc.getComments().get(0).getBody().getParagraphs().get(2).getChildObjects().removeAt(0);
doc.getComments().get(0).getBody().getParagraphs().get(2).appendPicture("2.png");
//保存文档
doc.saveToFile("ModifyComment.docx",FileFormat.Docx_);
}
}