Some test text!

Getting started

keyboard_arrow_down
Running samplesTry demo in your projectDownloading PDFTronIntegrating PDFTron via GradleManually integrating PDFTronUpgradingAdding PDFTron license keyUsing ProGuardTroubleshooting integration

Fundamentals

keyboard_arrow_down
Document lockingSaving PDF documentsUnderstanding coordinates

Basics

keyboard_arrow_down
Using an ActivityUsing a FragmentUsing PDFViewCtrlViewer configConverting and viewing other document typesConverting HTML to PDF

Viewer

keyboard_arrow_down
PDFViewCtrl color modesPDFViewCtrl page view modePDFViewCtrl page presentation modeGenerating thumbnails in PDF

Features

keyboard_arrow_down
Day/Night themesUndo and redoText searchAnnotation syncingRotating PDF pagesPDFViewCtrl read onlyUsing PDFViewCtrl with minimum memory

Tools

keyboard_arrow_down
Tools overviewSetting Up ToolManagerChanging and disabling toolsIntercepting annotation handlingToolManager eventsDefault annotation propertiesTool subclasses

Annotations

keyboard_arrow_down
Deleting annotationsAnnotation styleShow/hide annotations

UI components

keyboard_arrow_down
Quick menuAnnotation toolbarAnnotation style dialogThumbnail sliderAnnotations listOutline listUser bookmarks listBookmarks dialogPage thumbnails dialogAdd page dialogRotate pages dialogView mode dialogCrop page dialogReflow

Advanced

keyboard_arrow_down
Adding a custom view to a PDF pageCustom toolCustomizing quick menuCustomizing annotation style dialog

FAQ

keyboard_arrow_down
Running project in Android StudioSystem RequirementsPDFTron full vs. standardLocalizationIcon cheat sheetRunning sample with sourceReducing size of APKEnable multidexOut of memory when rotating device multiple timesDetachCurrentThread warning

PDF Processing API

keyboard_arrow_down
What is PDFNet?Opening a documentSerializing (saving) a documentWorking with pagesWorking with Page ContentWorking with BookmarksWorking with Interactive Forms (AcroForms)PDF SecurityLow-level PDF APIError handling
Annotation toolbarkeyboard_arrow_down

Annotation toolbar

In this document
chevron_rightShow/hide annotation toolbar
chevron_rightHide annotation toolbar items
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 and switch between different tools.

To learn about each icon, see the icon cheat sheet.
Due to space limitations, only a limited number of tools will show on portrait mode of smaller devices.
ScenarioAnnotation Toolbar
Small devices in landscape mode + Tablet devices
Small devices in portrait mode

linkShow/hide annotation toolbar

The annotation toolbar allows the user to easily switch tools when adding annotations to the document. To set up your layout with annotation toolbar, add a <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="?attr/actionBarSize"
    android:elevation="@dimen/actionbar_elevation"/>

Then, you need to attach a ToolManager to the annotation toolbar:



To close the annotation toolbar programmatically call:



Handle rotation:



linkHide annotation toolbar items

If there are tools that you would like to remove from the annotation toolbar, you can disable them via ToolManager.disableToolMode API. For example:



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

Portrait:

Landscape:

linkUndo/Redo

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

linkListeners

linkAnnotation toolbar listener

You can set a listener via setAnnotationToolbarListener(AnnotationToolbarListener) to be notified when the annotation toolbar is displayed or hidden. In addition, the listener should implement onShowAnnotationToolbarByShortcut(int) in order to show the annotation toolbar starting in a given tool mode. The method is invoked when the user presses a shortcut that would bring up the annotation toolbar. This listener is useful, for example, in order to keep the annotation toolbar hidden if the document has read-only access.

Example



linkUndo/Redo listener

To be notified when undo/redo buttons are clicked you should call AnnotationToolbar.setOnUndoRedoListener(OnUndoRedoListener).

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 annotation toolbar, you can define annotation_toolbar style inside your 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

linkapp:colorBackground

Specifies the annotation toolbar background color

Format: color

Default value: ?attr/colorPrimary

linkapp:colorToolBackground

Specifies the background color of each tool in annotation toolbar

Format: color

Default value: ?attr/colorPrimaryDark

linkapp:colorToolIcon

Specifies the icon color of each tool (except the close button) in annotation toolbar

Format: color

Default value: @android:color/white

linkapp:colorCloseIcon

Specifies the icon color of the close button in annotation toolbar

Format: color

Default value: @android:color/white