Skip to content

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.

AndroidiOS

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:

dart
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)

The customized toolbar will look like what’s shown below.

AndroidiOS

Available Toolbar Customization Options

Toolbar Button ItemDescription
backShows close button item.
thumbnailShows thumbnails button item.
searchShows search button item.
botaShows outline, bookmarks, annotation list button item.
menuShows 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 ItemDescription
viewSettingsOpen the settings view and set the scrolling direction,
display mode, theme color and other related settings for reading PDF.
documentEditorOpen the document thumbnail list, and you can delete, rotate, and add document pages in the view.
documentInfoOpen the document information view to display basic document information and permission information.
watermarkOpen the watermark editing view to add text and image watermarks and save them as a new document.
securityOpen the security settings view, set the document opening password and set the permission password
flattenedFlatten the annotations in the document, and the annotations will not be editable.
savesave pdf document.
shareTurn on system sharing function.
openDocumentOpen the system file selector and open a new pdf document.

Note: Please refer to ToolbarMenuAction for the relevant options.