<dependency>
    <groupId>com.groupdocs</groupId>
    <artifactId>groupdocs-annotation</artifactId>
    <version>23.8</version>
</dependency>
copied!  
compile(group: 'com.groupdocs', name: 'groupdocs-annotation', version: '23.8')
copied!  
<dependency org="com.groupdocs" name="groupdocs-annotation" rev="23.8">
    <artifact name="groupdocs-annotation" ext="jar"/>
</dependency>
copied!  
libraryDependencies += "com.groupdocs" % "groupdocs-annotation" % "23.8"
copied!  

产品 文档 演示 API 参考 示例 博客 支持 许可

GroupDocs.Annotation for Java 23.8 中的新功能

概览

GroupDocs.Annotation for Java 的 23.8 版本带来了一个重要的新功能以及关键的错误修复。本次更新增强了文档的可用性和交互性,并确保文档和 API 参考是最新的。

主要功能

向文档添加组件

  • 按钮组件: 现在可以在文档中嵌入交互式按钮,增强用户互动。
  • 下拉列表组件: 创建下拉列表,以便更好地收集数据和用户自定义。
  • 复选框组件: 在文档中引入复选框,用于任务跟踪或条件互动。

修复

  • 波浪线注释文档: 缺少的波浪线注释文章已恢复到文档中,为用户提供了详细的使用指南。
  • API 参考更新: 所有 API 参考都已更新,确保用户可以访问最新信息。

代码示例

添加按钮组件

以下代码片段演示了如何向 PDF 文档添加一个按钮组件。按钮可以通过位置、边框样式、颜色等各种属性进行自定义,还可以包含评论。

try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
    // 实例化一个 ButtonComponent 并设置其属性
    ButtonComponent buttonComponent = new ButtonComponent();
    buttonComponent.setCreatedOn(new Date()); // 设置创建日期
    buttonComponent.setStyle(BorderStyle.DASHED); // 将边框样式设置为虚线
    buttonComponent.setMessage("这是一个按钮组件"); // 设置按钮的标签文本
    buttonComponent.setBorderColor(1422623); // 设置边框颜色
    buttonComponent.setPenColor(14527697); // 设置笔(框架)颜色
    buttonComponent.setButtonColor(10832612); // 设置按钮的填充颜色
    buttonComponent.setPageNumber(0); // 指定按钮将放置在哪一页
    buttonComponent.setBorderWidth(12); // 设置按钮边框的宽度
    buttonComponent.setBox(new Rectangle(100, 300, 90, 30)); // 设置按钮的位置和大小

    // 向按钮添加评论(回复)
    Reply reply1 = new Reply();
    reply1.setComment("第一条评论");
    reply1.setRepliedOn(new Date());

    Reply reply2 = new Reply();
    reply2.setComment("第二条评论");
    reply2.setRepliedOn(new Date());

    List<Reply> replies = new ArrayList<>();
    replies.add(reply1);
    replies.add(reply2);

    buttonComponent.setReplies(replies); // 将回复附加到按钮上

    // 将按钮组件添加到文档中
    annotator.add(buttonComponent);

    // 保存包含按钮组件的修改后的文档
    annotator.save("result_button_component.pdf");
}

来源*

添加复选框组件

此代码片段显示了如何向 PDF 文档添加一个复选框组件。复选框可以通过是否选中、颜色和样式等属性进行自定义。

try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
    // 实例化一个 CheckBoxComponent 并设置其属性
    CheckBoxComponent checkbox = new CheckBoxComponent();
    checkbox.setChecked(true); // 将复选框设置为选中
    checkbox.setBox(new Rectangle(100, 100, 100, 100)); // 设置复选框的位置和大小
    checkbox.setPenColor(65535); // 设置笔(框架)颜色
    checkbox.setStyle(BoxStyle.STAR); // 设置复选框样式(例如,星形)

    // 向复选框添加评论(回复)
    Reply reply1 = new Reply();
    reply1.setComment("第一条评论");
    reply1.setRepliedOn(new Date());

    Reply reply2 = new Reply();
    reply2.setComment("第二条评论");
    reply2.setRepliedOn(new Date());

    List<Reply> replies = new ArrayList<>();
    replies.add(reply1);
    replies.add(reply2);

    checkbox.setReplies(replies); // 将回复附加到复选框上

    // 将复选框组件添加到文档中
    annotator.add(checkbox);

    // 保存包含复选框组件的修改后的文档
    annotator.save("result_checkbox_component.pdf");
}

来源*

添加下拉组件

以下代码展示了如何向 PDF 文档添加一个下拉(组合框)组件。该组件可以包含可选项列表,其外观可以通过边框样式和颜色等属性进行自定义。

try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
    // 实例化一个 DropdownComponent 并设置其属性
    DropdownComponent dropdownComponent = new DropdownComponent();
    dropdownComponent.setOptions(new ArrayList<>(Arrays.asList("选项1", "选项2", "选项3"))); // 设置下拉选项
    dropdownComponent.setSelectedOption(null); // 默认情况下未选择任何选项
    dropdownComponent.setPlaceholder("选择选项"); // 设置占位符文本
    dropdownComponent.setBox(new Rectangle(100, 100, 100, 100)); // 设置下拉的位置和大小
    dropdownComponent.setCreatedOn(new Date()); // 设置创建日期
    dropdownComponent.setMessage("这是一个下拉组件"); // 设置下拉的标签文本
    dropdownComponent.setPageNumber(0); // 指定页码
    dropdownComponent.setPenColor(65535); // 设置笔(框架)颜色
    dropdownComponent.setPenStyle(PenStyle.DOT); // 将框架线样式设置为点状
    dropdownComponent.setPenWidth((byte) 3); // 将框架线宽度设置为像素

    // 向下拉菜单添加评论(回复)
    List<Reply> replies = new ArrayList<>();
    Reply reply1 = new Reply();
    reply1.setComment("第一条评论");
    reply1.setRepliedOn(new Date());

    Reply reply2 = new Reply();
    reply2.setComment("第二条评论");
    reply2.setRepliedOn(new Date());

    replies.add(reply1);
    replies.add(reply2);

    dropdownComponent.setReplies(replies); // 将回复附加到下拉菜单上

    // 将下拉组件添加到文档中
    annotator.add(dropdownComponent);

    // 保存包含下拉组件的修改后的文档
    annotator.save("result_dropdown_component.pdf");
}

来源*

🔍 探索完整的发布详情

要查看此版本中引入的所有新功能、增强功能和错误修复的完整列表,请访问 **[GroupDocs.Annotation for Java

23.8 发布说明](https://releases.groupdocs.com/annotation/java/release-notes/2023/groupdocs-annotation-for-java-23-8-release-notes/)** 页面。

产品 文档 演示 API 参考 示例 博客 支持 许可

VersionRelease Date
24.62024年6月30日
23.102023年10月9日
23.82023年8月28日
23.62023年6月23日
23.42023年4月17日
23.22023年4月16日
21.7.22022年1月25日
21.7.12022年1月25日
2.0.02022年1月25日
19.22022年1月25日
17.102022年1月25日
17.10.32022年1月25日
1.5.02022年1月25日
21.72021年7月21日
19.72020年2月19日
20.22020年2月13日
19.52019年5月30日
19.42019年4月15日
18.12018年10月16日
18.102018年10月16日
1.4.02018年4月18日
1.6.02018年4月18日
1.7.02018年4月18日
1.7.12018年4月18日
1.8.02018年4月18日
1.8.12018年4月18日
1.8.22018年4月18日
1.9.02018年4月18日
17.1.02018年4月18日
17.10.12018年4月18日
17.10.22018年4月18日
17.5.02018年4月18日
17.6.02018年4月18日
18.42018年4月18日
3.1.02018年4月18日