Customize ToolManager

You will need to use ToolManager for PDF interaction tools to work. You can build it easily using ToolManagerBuilder, a helper class for configuring and creating ToolManager. It also sets ToolManager to a specific PDFViewCtrl.

Build a default ToolManager

To build a default ToolManager, use ToolManagerBuilder and pass in an instance of PDFViewCtrl:

1ToolManager mToolManager = ToolManagerBuilder.from()
2 .build(getActivity(), pdfViewCtrl);

Build a custom ToolManager programmatically

You can customize the ToolManager programmatically with ToolManagerBuilder:

1ToolManager mToolManager = ToolManagerBuilder.from()
2 .setEditInk(true)
3 .setOpenToolbar(true)
4 .setBuildInPageIndicator(false)
5 .setCopyAnnot(true)
6 .disableToolModes(new ToolManager.ToolMode[]{
7 ToolManager.ToolMode.TEXT_ANNOT_CREATE,
8 ToolManager.ToolMode.TEXT_CREATE,
9 ToolManager.ToolMode.TEXT_SQUIGGLY,
10 ToolManager.ToolMode.INK_ERASER,
11 ToolManager.ToolMode.FORM_CHECKBOX_CREATE,
12 ToolManager.ToolMode.RECT_CREATE,
13 ToolManager.ToolMode.TEXT_LINK_CREATE
14 })
15 .build(getActivity(), pdfViewCtrl);

Supporting image stamp and image signatures

Image stamps and image signatures require a source image in order to create the annotation. If you are using PDFViewCtrl with ToolManager, will need to handle this manually in your app by implementing the methods ToolManager.AdvancedAnnotationListener.imageStamperSelected(PointF) and ToolManager.AdvancedAnnotationListener.imageSignatureSelected(PointF, int, Long).

For reference you can check out our PDFViewCtrl integration guide here

Build a custom ToolManager with style

You can also customize the ToolManager by defining an Android style resource and passing it to ToolManagerBuilder:

  1. Create a custom style in your res/values/styles.xml file:For additional customization, a list of supported style attributes are defined in this table.

XML

1<style name="MyToolManager"> <!-- allow editing ink annotations (only works if annotation toolbar is present) --> <item name="edit_ink_annots">true</item> <!-- when ink selected in annotation toolbar, it should open its own ink toolbar --> <item name="open_toolbar_on_pan_ink_selected">true</item> <!-- hide the built-in page number indicator --> <item name="build_in_page_number_indicator">false</item> <!-- whether to copy marked-up text of TextMarkup annot to annotation's 'content' property upon TextMarkup annotation creation --> <item name="copy_annotated_text_to_note">true</item> <!-- remove some tools from AnnotationToolbarComponent and QuickMenu --> <item name="disable_tool_modes">@array/disable_tool_modes</item> </style>
  1. In the previous step, @array/disable_tool_modes is a string array defining tool modes that should be disabled. You can define it in res/values/arrays.xml:Each <item> in the array needs to be a string matching one of the enum values from ToolManager.ToolMode.

XML

1<?xml version="1.0" encoding="utf-8"?>
2<resources>
3 <string-array name="disable_tool_modes">
4 <item>TEXT_ANNOT_CREATE</item>
5 <item>TEXT_CREATE</item>
6 <item>TEXT_SQUIGGLY</item>
7 <item>INK_ERASER</item>
8 <item>FORM_CHECKBOX_CREATE</item>
9 <item>RECT_CREATE</item>
10 <item>TEXT_LINK_CREATE</item>
11 </string-array>
12</resources>

You can also set up ToolManagerBuilder programmatically. For a list of settings available, see the ToolManagerBuilder API.

  1. Lastly, build the ToolManager using ToolManagerBuilder and pass in your custom style and an instance of PDFViewCtrl:Alternatively, you can pass the ToolManager style resource directly to ViewerConfig.Builder. You can learn more about configuring ToolManager with ViewerConfig in the viewer configuration guides.
1ToolManager mToolManager = ToolManagerBuilder.from(context, R.style.MyToolManager)
2 .build(getActivity(), pdfViewCtrl);

XML style attributes

Attributes

Description

Format

edit_ink_annots

Controls whether editing ink annotations is allowed (only works if annotation toolbar is present)

Default value: false

Format: boolean

open_toolbar_on_pan_ink_selected

Whether annotation toolbar should open when Ink is selected from quick menu (only works if annotation toolbar is present)

Default value: false

Format: boolean

build_in_page_number_indicator

Whether to use/show the built-in page number indicator

Default value: true

Format: boolean

annot_permission_check

Whether to check annotation author's permission

Default value: false

Format: boolean

show_author_dialog

Whether to show author dialog the first time the user annotates

Default value: false

Format: boolean

copy_annotated_text_to_note

Whether to copy marked-up text of TextMarkup annot to annotation's 'content' property upon TextMarkup annotation creation

Default value: false

Format: boolean

stylus_as_pen

Whether to enable using stylus to draw without having to enter ink tool

Default value: false

Format: boolean

ink_smoothing_enabled

Whether to smooth ink annotations

Default value: true

Format: boolean

auto_select_annotation

Whether to auto-select annotations after they are created

Default value: true

Format: boolean

quick_menu_disable

Whether disable showing quick menu

Default value: false

Format: boolean

double_tap_to_zoom

Whether double-tapping should zoom the viewer

Default value: true

Format: boolean

auto_resize_freetext

Whether can auto resize free text bounding box when editing

Default value: false

Format: boolean

realtime_annot_edit

Whether annotation editing is real time

Default value: true

Format: boolean

edit_freetext_on_tap

Whether can edit freetext on tap

Default value: false

Format: boolean

show_saved_signatures

Whether can show saved signatures in signature dialog

Default value: true

Format: boolean

show_annot_indicator

Whether can show indicator for annotations with comments

Default value: true

Format: boolean

disable_tool_modes

Array of tools to disable

Default value: null

Format: reference

disable_annot_editing_by_types

Array of annotation types to disable editing

Default value: null

Format: reference

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales