java word 批注_Java 添加Word批注(文本、图片)

import com.spire.doc.*;

import com.spire.doc.documents.Paragraph;

import com.spire.doc.fields.Comment;

public class AddComment {

public static void main(String[] args) {

//加载测试文档

Document doc = new Document("test.docx");

//获取指定段落

Section sec = doc.getSections().get(0);

Paragraph para= sec.getParagraphs().get(3);

//插入文本到批注

Comment comment = para.appendComment("请在试验中将包含以下特征的实验样本记录在册,并整理好周记录报表,供后续观察取样。");

comment.getFormat().setAuthor("审校组");

//插入图片到批注

comment.getBody().addParagraph().appendPicture("tp.png");

//保存文档

doc.saveToFile("AddComment.docx", FileFormat.Docx_2010);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值