Main Toolbar
The main toolbar in ComPDFKit is designed to be flexible and highly configurable. This guide shows how to customize it.
Default Toobar
The default toolbar contains the following tools.
Android | iOS |
---|---|
Customizing the Toolbar Buttons
You can customize the main toolbar buttons when displaying a PDF using the iosLeftBarAvailableActions
or iosRightBarAvailableActions
properties on iOS and the androidAvailableActions
property on Android. The following example shows how to hide the menu button in the navigation bar (main toolbar) on iOS and how to customize the Android toolbar menu items:
CPDFConfiguration configuration = CPDFConfiguration(toolbarConfig: const ToolbarConfig(
mainToolbarVisible : true,
androidAvailableActions: [
ToolbarAction.back,
ToolbarAction.search,
ToolbarAction.thumbnail,
ToolbarAction.bota,
ToolbarAction.menu,
],
iosLeftBarAvailableActions: [
ToolbarAction.back,
ToolbarAction.thumbnail
],
iosRightBarAvailableActions: [
ToolbarAction.search,
ToolbarAction.bota,
],
));
// CPDFReaderWidget Sample
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(),
body: CPDFReaderWidget(
document: documentPath,
configuration: configuration,
onCreated: (controller) {},
));
// ComPDFKit.openDocument Sample
ComPDFKit.openDocument(documentPath, '', configuration)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
The customized toolbar will look like what’s shown below.
Android | iOS |
---|---|
Available Toolbar Customization Options
Toolbar Button Item | Description |
---|---|
back | Shows close button item. |
thumbnail | Shows thumbnails button item. |
search | Shows search button item. |
bota | Shows outline, bookmarks, annotation list button item. |
menu | Shows menu button item. |
Note: Please refer to ToolbarAction for the relevant options.
Available menu Customization options
If you configure ToolbarAction.menu
, you can access more functional buttons in the menu. For configurable options, please refer to the following list.
Menu Button Item | Description |
---|---|
viewSettings | Open the settings view and set the scrolling direction, display mode, theme color and other related settings for reading PDF. |
documentEditor | Open the document thumbnail list, and you can delete, rotate, and add document pages in the view. |
documentInfo | Open the document information view to display basic document information and permission information. |
watermark | Open the watermark editing view to add text and image watermarks and save them as a new document. |
security | Open the security settings view, set the document opening password and set the permission password |
flattened | Flatten the annotations in the document, and the annotations will not be editable. |
save | save pdf document. |
share | Turn on system sharing function. |
openDocument | Open the system file selector and open a new pdf document. |
Note: Please refer to ToolbarMenuAction for the relevant options.