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:

tsx
let config = ComPDFKit.getDefaultConfig({
  toolbarConfig: {
    // only ios platform
    iosLeftBarAvailableActions: [
      CPDFToolbarAction.BACK,
      CPDFToolbarAction.THUMBNAIL
    ],
    // only ios platform
    iosRightBarAvailableActions: [
      CPDFToolbarAction.SEARCH,
      CPDFToolbarAction.BOTA
    ],
    // only android platform
    androidAvailableActions: [
      // The back button will only appear on the far left side of the toolbar
      CPDFToolbarAction.BACK,
      CPDFToolbarAction.SEARCH,
      CPDFToolbarAction.THUMBNAIL,
      CPDFToolbarAction.BOTA,
      CPDFToolbarAction.MENU
    ]
  }
});
ComPDFKit.openDocument(_document, '', config);

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 CPDFToolbarAction for the relevant options.

Available menu Customization options

If you configure CPDFToolbarAction.MENU, you can access more functional buttons in the menu. For configurable options, please refer to the following list.

Menu Button ItemDescription
VIEW_SETTINGSOpen the settings view and set the scrolling direction,
display mode, theme color and other related settings for reading PDF.
DOCUMENT_EDITOROpen the document thumbnail list, and you can delete, rotate, and add document pages in the view.
DOCUMENT_INFOOpen 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.
OPEN_DOCUMENTOpen the system file selector and open a new pdf document.

Note: Please refer to CPDFToolbarMenuAction for the relevant options.