注释工具栏
在 ComPDFKit 中,注释工具栏可以灵活配置,使用户能够选择注释类型和工具。本节将介绍如何自定义注释工具栏。
默认注释工具栏
默认的注释工具栏包含以下注释类型和工具:
| Android | iOS |
|---|---|
![]() | ![]() |
自定义工具栏按钮
您可以通过在 annotationsConfig 对象中设置 availableTypes 属性来启用或隐藏特定的注释类型。以下示例演示了如何只显示注释和高亮注释类型。
dart
CPDFConfiguration configuration = CPDFConfiguration(
annotationsConfig: const CPDFAnnotationsConfig(availableTypes: [
CPDFAnnotationType.note,
CPDFAnnotationType.highlight
], availableTools: [
CPDFConfigTool.setting,
CPDFConfigTool.undo,
CPDFConfigTool.redo,
]));
// CPDFReaderWidget 示例
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(),
body: CPDFReaderWidget(
document: documentPath,
configuration: configuration,
onCreated: (controller) {},
));
// ComPDFKit.openDocument 示例
ComPDFKit.openDocument(documentPath, '', configuration)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
自定义的工具栏将如下所示。
| Android | iOS |
|---|---|
![]() | ![]() |
可用的工具栏自定义选项
类型
| note | highlight | underline | squiggly | strikeout | ink |
|---|---|---|---|---|---|
| pencil | circle | square | arrow | line | freetext |
| signature | stamp | pictures | link | sound |
注意:请参考 CPDFAnnotationType获取相关选项。请注意
pencil仅在 iOS 上可用。
可用的工具栏工具自定义选项
| 工具 | 描述 |
|---|---|
| setting | 设置按钮,对应打开所选注释、文本或图片属性面板。 |
| undo | 撤销注释、内容编辑、表单操作。 |
| redo | 重做被撤销的操作。 |
注意:请参考 CPDFConfigTool 获取相关选项。
显示或隐藏工具栏
可以通过配置 CPDFConfiguration 来控制注释模式下底部工具栏的显示状态。
dart
CPDFConfiguration configuration = CPDFConfiguration(
// 设置注释模式底部工具栏是否可见
toolbarConfig: const CPDFToolbarConfig(annotationToolbarVisible: false),
);1
2
3
4
2
3
4



