Skip to content
Guides

注释工具栏

注释模式下,底部会显示注释工具栏(CAnnotationToolbar),供用户选择注释类型和工具。通过 AnnotationsConfig 可配置可用的注释类型、工具按钮及行为开关。

可用注释类型

availableTypes 控制注释工具栏中显示的注释类型按钮。未在列表中的类型将被隐藏:

json
{
  "annotationsConfig": {
    "availableTypes": [
      "note",
      "highlight",
      "underline",
      "squiggly",
      "strikeout",
      "ink",
      "ink_eraser",
      "circle",
      "square",
      "arrow",
      "line",
      "freetext",
      "signature",
      "stamp",
      "pictures",
      "link",
      "sound"
    ]
  }
}

注释类型说明

说明
note便签注释
highlight高亮
underline下划线
squiggly波浪线
strikeout删除线
ink手写/画笔
ink_eraser橡皮擦
circle圆形/椭圆
square矩形
arrow箭头
line直线
freetext文本框
signature手写签名
stamp图章
pictures图片注释
link链接
sound音频注释

如果只需高亮和手写功能:

json
{
  "annotationsConfig": {
    "availableTypes": [
      "highlight",
      "ink"
    ]
  }
}

可用工具

availableTools 控制注释工具栏右侧的工具按钮:

json
{
  "annotationsConfig": {
    "availableTools": [
      "setting",
      "undo",
      "redo"
    ]
  }
}
说明
setting属性设置按钮,点击打开当前注释类型的属性编辑面板
undo撤销
redo重做

如果工具列表为空,工具区域 UI 将被隐藏。

注释作者

json
{
  "annotationsConfig": {
    "annotationAuthor": "Guest"
  }
}

创建注释时将使用此名称作为注释作者。

行为开关

字段类型默认值说明
autoShowSignPickerbooleantrue选中签名工具后是否自动弹出签名选择器
autoShowStampPickerbooleantrue选中图章工具后是否自动弹出图章选择器
autoShowPicPickerbooleantrue选中图片工具后是否自动弹出图片选择器
autoShowLinkDialogbooleantrue创建链接注释后是否自动弹出链接编辑对话框
interceptNoteActionbooleanfalse是否拦截便签注释的默认点击行为(拦截后可通过回调自定义处理)
interceptLinkActionbooleanfalse是否拦截链接注释的默认点击行为
json
{
  "annotationsConfig": {
    "autoShowSignPicker": true,
    "autoShowStampPicker": true,
    "autoShowPicPicker": true,
    "autoShowLinkDialog": true,
    "interceptNoteAction": false,
    "interceptLinkAction": false
  }
}

CAnnotationToolbar 组件

CAnnotationToolbar 是注释工具栏的核心 UI 组件,位于 com.compdfkit.tools.annotation.pdfannotationbar 包中。

相关类:

说明
CAnnotationToolbar注释工具栏主视图
CPDFAnnotationToolListAdapter注释类型列表适配器
CAnnotToolBean注释工具项数据模型
CAnnotationToolDatas注释工具栏数据源

在使用源码集成时,可直接修改这些类以实现更深度的定制。