流程
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中添加注释的详细内容。更多信息请关注PHP中文网其他相关文章!

本文讨论了使用Maven和Gradle进行Java项目管理,构建自动化和依赖性解决方案,以比较其方法和优化策略。

本文使用Maven和Gradle之类的工具讨论了具有适当的版本控制和依赖关系管理的自定义Java库(JAR文件)的创建和使用。

本文讨论了使用咖啡因和Guava缓存在Java中实施多层缓存以提高应用程序性能。它涵盖设置,集成和绩效优势,以及配置和驱逐政策管理最佳PRA

本文讨论了使用JPA进行对象相关映射,并具有高级功能,例如缓存和懒惰加载。它涵盖了设置,实体映射和优化性能的最佳实践,同时突出潜在的陷阱。[159个字符]

Java的类上载涉及使用带有引导,扩展程序和应用程序类负载器的分层系统加载,链接和初始化类。父代授权模型确保首先加载核心类别,从而影响自定义类LOA


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)