Setting up ToolManager

In this document
chevron_rightBuild ToolManager

You will need to use ToolManager for PDF interaction tools to work. You can build it easily using ToolManagerBuilder. ToolManagerBuilder is a helper class for constructing ToolManager with style resource configuration. It also sets ToolManager to PDFViewCtrl.

Build ToolManager

To build a default ToolManager, do the following:

ToolManager mToolManager = ToolManagerBuilder.from().build(pdfViewCtrl);

where pdfViewCtrl is the instance of PDFViewCtrl.

You can also customize the ToolManager by creating a custom style. For example, you can add the following to your styles.xml file:

<style name="MyToolManager">
    <!-- allow editing ink annotations (only works if annotation toolbar is present) -->
    <item name="edit_ink_annots">true</item>
    <!-- disable image stamper tool -->
    <item name="add_image_stamper_tool">false</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 AnnotationToolbar and QuickMenu -->
    <item name="disable_tool_modes">@array/disable_tool_modes</item>
</style>

In the preceding, @array/disable_tool_modes is a string array defined in values/arrays.xml. For example:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="disable_tool_modes">
        <item>TEXT_ANNOT_CREATE</item>
        <item>TEXT_CREATE</item>
        <item>TEXT_SQUIGGLY</item>
        <item>INK_ERASER</item>
        <item>FORM_CHECKBOX_CREATE</item>
        <item>RECT_CREATE</item>
        <item>TEXT_LINK_CREATE</item>
    </string-array>
</resources>

Each 'item' in the preceding is, and should be, a string matching one of the enum values from ToolManager.ToolMode.

You can also set up ToolManagerBuilder programmatically. For more details, see the ToolManagerBuilder API
.

Lastly, build ToolManager:

ToolManager mToolManager = ToolManagerBuilder.from(context, R.style.MyToolManager)
    .build(pdfViewCtrl);

(pdfViewCtrl is the instance of PDFViewCtrl.)

XML style attributes

edit_ink_annots

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

format: boolean

default value: false

add_image_stamper_tool

Controls whether image stamper tool is enabled

format: boolean

default value: false

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)

format: boolean

default value: false

build_in_page_number_indicator

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

format: boolean

default value: true

annot_permission_check

Whether to check annotation author's permission

format: boolean

default value: false

show_author_dialog

Whether to show author dialog the first time the user annotates

format: boolean

default value: false

copy_annotated_text_to_note

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

format: boolean

default value: false

stylus_as_Pen

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

format: boolean

default value: false

ink_smoothing_enabled

Whether to smooth ink annotations

format: boolean

default value: true

auto_select_annotation

Whether to auto-select annotations after they are created

format: boolean

default value: true

double_tap_to_zoom

Whether double-tapping should zoom the viewer

format: boolean

default value: true

disable_tool_modes

Array of tools to disable

format: reference

default value: null