Java怎么在PDF中添加注释

这篇文章主要讲解了“Java怎么在PDF中添加注释”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Java怎么在PDF中添加注释”吧!

从化ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

流程

1、使用Document类加载PDF文档。

2、创建TextAnnotation对象,添加文本注释。

3、设定标题、主题等注释属性。

4、使用Border类设置注释的Border。

使用Document.getPages().get_Item(int).getAnnotations().add(Annotation)方法向文档添加注释。

5、用Document.save保存更新的PDF。

实例

// Open the source PDF document
Document pdfDocument = new Document("input.pdf");
 
// Create annotation
TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.getPages().get_Item(1), new com.aspose.pdf.Rectangle(200, 400, 400, 600));
 
// Set annotation title
textAnnotation.setTitle("Sample Annotation Title");
 
// Set annotation subject
textAnnotation.setSubject("Sample Subject");
textAnnotation.setState(AnnotationState.Accepted);
 
// Specify the annotation contents
textAnnotation.setContents("Sample contents for the annotation");
textAnnotation.setOpen(true);
textAnnotation.setIcon(TextIcon.Key);
Border border = new Border(textAnnotation);
border.setWidth(5);
border.setDash(new Dash(1, 1));
textAnnotation.setBorder(border);
textAnnotation.setRect(new com.aspose.pdf.Rectangle(200, 400, 400, 600));
 
// Add annotation in the annotations collection of the page
pdfDocument.getPages().get_Item(1).getAnnotations().add(textAnnotation);
 
// Save the output file
pdfDocument.save("output.pdf");

感谢各位的阅读,以上就是“Java怎么在PDF中添加注释”的内容了,经过本文的学习后,相信大家对Java怎么在PDF中添加注释这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!

当前名称:Java怎么在PDF中添加注释
文章位置:https://www.cdcxhl.com/article34/jiecse.html

成都网站建设公司_创新互联,为您提供网站导航域名注册软件开发标签优化网站内链网站设计公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网页设计公司