内容编辑工具栏
在 ComPDFKit 中,内容编辑工具栏可以灵活配置,使用户能够选择编辑类型和工具。本节将介绍如何自定义内容编辑工具栏。
默认内容编辑工具栏
默认的内容编辑工具栏包含以下编辑类型和工具:
| Android | iOS |
|---|---|
![]() | ![]() |
自定义工具栏按钮
您可以通过在 contentEditorConfig 对象中设置 availableTypes 属性来启用或隐藏特定的编辑类型。以下示例演示了如何调整编辑类型的顺序,并隐藏内容编辑工具的设置按钮。
dart
CPDFConfiguration configuration = CPDFConfiguration(
contentEditorConfig: const CPDFContentEditorConfig(availableTypes: [
CPDFContentEditorType.editorImage,
CPDFContentEditorType.editorText
], availableTools: [
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
自定义的工具栏将如下所示。
| Android | iOS |
|---|---|
![]() | ![]() |
可用的工具栏自定义选项
| 类型 |
|---|
| CPDFContentEditorType.editorText |
| CPDFContentEditorType.editorImage |
注意:请参考 CPDFContentEditorType 获取相关选项。
可用的工具自定义选项
| 工具 | 描述 |
|---|---|
| setting | 设置按钮,对应打开所选注释、文本或图片属性面板。 |
| undo | 撤销注释、内容编辑、表单操作。 |
| redo | 重做被撤销的操作。 |
注意:请参考 CPDFConfigTool 获取相关选项。
显示或隐藏工具栏
可以通过配置 CPDFConfiguration 来控制内容编辑模式下底部工具栏的显示状态。
dart
CPDFConfiguration configuration = CPDFConfiguration(
// 设置内容编辑模式底部工具栏是否可见
toolbarConfig: const CPDFToolbarConfig(contentEditorToolbarVisible: false),
);1
2
3
4
2
3
4



