Some test text!

keyboard_arrow_down

Get started

Quick start - view a documentDownload PDFTron SDKIntegrate with GradleIntegrate manuallyRun samplesAdd license keyUpdate to latest versionTroubleshooting
keyboard_arrow_down

FAQ

System requirementsDocument lockingDocument savingRun project in Android StudioRun project with source codePDFTron full vs. standardReduce size of APK
keyboard_arrow_down

Document Viewer

OverviewShow a document in an ActivityShow a document in a FragmentViewer configurationToolManager configurationDay and Night themesOpen from online URL
keyboard_arrow_down

Document Viewer components

OverviewPDFViewCtrlReflowQuick menuCustomize quick menuAnnotation toolbarAnnotation style editorCustomize annotation style editorPage sliderList containerAnnotation listDocument outlineUser bookmark listThumbnail browserAdd pages dialogCrop pages dialogRotate pages dialogView mode dialog
keyboard_arrow_down

Annotation and collaboration

OverviewRead only modeDisable annotation creation and editingDefault annotation propertiesChange tool modeEventsOverride annotation handlingShow and hide existing annotationsUndo and redoRealtime collaboration
keyboard_arrow_down

Advanced customization

OverviewAdd a custom view to a pageCreate a custom toolPage coloring modePage fit modePage layout modeScrolling directionRight-to-left support
keyboard_arrow_down

Conversion

keyboard_arrow_down

Parsing and extraction

keyboard_arrow_down

Digital signatures

Overview
keyboard_arrow_down

Search

keyboard_arrow_down

Advanced topics

PrintUnderstand coordinatesGenerate page thumbnailsChange annotation propertiesDelete annotationsTool class hierarchy
keyboard_arrow_down

Other frameworks

keyboard_arrow_down

Troubleshooting

keyboard_arrow_down

Reference

keyboard_arrow_down

PDF Processing API

Annotation toolbarkeyboard_arrow_down

Annotation toolbar

In this document
chevron_rightShow and hide annotation toolbar
chevron_rightHide annotation toolbar items
chevron_rightHide tool buttons
chevron_rightHide other buttons
chevron_rightRemove default tool grouping
chevron_rightUndo/Redo
chevron_rightListeners
chevron_rightAnnotation toolbar listener
chevron_rightUndo/Redo listener
chevron_rightContinuous annotation edit
chevron_rightAppearance styling
chevron_rightXML attributes

AnnotationToolbar is a FrameLayout consisting of various annotation creation tools. With the annotation toolbar, users are able to conveniently create annotations and switch between different tools.

To learn more about each icon, see the icon cheat sheet.
Screen SizeAnnotation Toolbar
Tablets or small devices in landscape mode
Small devices in portrait mode
Due to screen size limitations, only a limited number of tool icons will show up in portrait mode of smaller devices. This can be expanded by expanding the toolbar in the overflow menu.

linkShow and hide annotation toolbar

The annotation toolbar allows the user to easily switch tools when adding annotations to a document. To set up your layout with an annotation toolbar, add an <AnnotationToolbar> element to your XML layout. For example, your layout may look like this:

<com.pdftron.pdf.controls.AnnotationToolbar
    android:id="@+id/annotationToolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="@dimen/actionbar_elevation"/>

Then in your activity, you attach a ToolManager to the annotation toolbar:

To close the annotation toolbar programmatically call:

To handle device rotation, call AnnotationToolbar.onConfigurationChanged(Configuration) in your activity:

linkHide annotation toolbar items

linkHide tool buttons

If there are tools that you would like to remove from the annotation toolbar, you can disable them by calling ToolManager.disableToolMode(ToolMode[]). This will also hide the tool in the quick menu. For example:

Then, when you open the annotation toolbar you will see:

In portrait mode:

In landscape mode:

For reference, a mapping of ToolMode to button icons is shown below:

IconToolMode
RECT_CREATE
OVAL_CREATE
POLYLINE_CREATE
POLYGON_CREATE
CLOUD_CREATE
LINE_CREATE
ARROW_CREATE
RULER_CREATE
TEXT_CREATE
CALLOUT_CREATE
TEXT_ANNOT_CREATE
INK_CREATE
INK_ERASER
SIGNATURE
STAMPER
RUBBER_STAMPER
FREE_HIGHLIGHTER
TEXT_HIGHLIGHT
TEXT_UNDERLINE
TEXT_SQUIGGLY
TEXT_STRIKEOUT
SOUND_CREATE
FILE_ATTACHMENT_CREATE
FORM_TEXT_FIELD_CREATE
FORM_CHECKBOX_CREATE
ANNOT_EDIT_RECT_GROUP

linkHide other buttons

If you would like to hide other buttons in the annotation toolbar that are not tied to any specific tool (e.g. Pan, Close, and Overflow buttons), you can do so by calling AnnotationToolbar.hideButton with a ToolbarButtonId from the table below:

IconToolbar Button Id
PAN
CLOSE
OVERFLOW

linkRemove default tool grouping

By default, annotation creation tools are grouped in four categories:

  • Open shape group: line, arrow, polyline, ruler
  • Closed shape group: rectangle, ellipse, polygon, cloud
  • FreeText group: free text, callout
  • Icon group: sticky note, sound

It is possible to change the default grouping, for example, to remove the last icon group:

linkUndo/Redo

If undo/redo is enabled in the PDFViewCtrl then the buttons for undo/redo will be provided as a popup window when the user clicks on the three vertical dots at the right end of the toolbar.

linkListeners

linkAnnotation toolbar listener

You can set an AnnotationToolbarListener to be notified of annotation toolbar events (such as the toolbar being shown or closed) by calling setAnnotationToolbarListener.

Example

In addition, the onShowAnnotationToolbarByShortcut(int) method is invoked when the user presses a shortcut that brings up the annotation toolbar. You should implement this method to start the annotation toolbar with a specific tool mode selected or to keep the annotation toolbar hidden if the document has read-only access.

linkUndo/Redo listener

To be notified when the undo/redo buttons are clicked, you should set an OnUndoRedoListener by calling setOnUndoRedoListener.

Example

linkContinuous annotation edit

By default, the annotation toolbar returns to the pan tool after an annotation is created. If you prefer to keep the same tool mode after an annotation is created you should call:

linkAppearance styling

In order to customize the appearance of UI elements in your annotation toolbar, you can define an annotation_toolbar style inside your res\values\style.xml file:

<style name="YourAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="colorPrimary">@color/app_color_primary_day</item>
    <item name="colorPrimaryDark">@color/app_color_primary_dark_day</item>
    <item name="colorAccent">@color/app_color_accent</item>

    <item name="annotation_toolbar">@style/CustomAnnotationToolbarStyle</item>
</style>

<style name="CustomAnnotationToolbarStyle" parent="AnnotationToolbarStyle">
    <item name="colorBackground">@android:color/black</item>
</style>

Alternatively, you can change the attributes inside your xml layout:

<com.pdftron.pdf.controls.AnnotationToolbar
  android:id="@+id/annotationToolbar"
    app:colorBackground="@android:color/black"
    ... 
/>

linkXML attributes

AttributeDescriptionFormat
app:colorBackgroundSpecifies the annotation toolbar background color.

Default value: ?attr/colorPrimary
Color
app:colorToolBackgroundSpecifies the background color of each tool in annotation toolbar.

Default value: ?attr/colorPrimaryDark
Color
app:colorToolIconSpecifies the icon color of each tool (except the close button) in annotation toolbar.

Default value: @android:color/white
Color
app:colorCloseIconSpecifies the icon color of the close button in annotation toolbar.

Default value: @android:color/white
Color