Some test text!

Get started

keyboard_arrow_down
Download PDFTron SDKIntegrate with GradleIntegrate manuallyRun samplesAdd PDFTron license keyQuick start - view a documentProGuardUpdate to latest versionTroubleshooting

Document Viewer

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

Document Viewer components

keyboard_arrow_down
PDFViewCtrlReflowFloating context menuCustomize floating context menuAnnotation toolbarAnnotation style dialogCustomize annotation style dialogPage sliderAnnotation listDocument outlineUser bookmark listList containerThumbnail browserAdd pages dialogRotate pages dialogView mode dialogCrop pages dialog

Annotation and collaboration

keyboard_arrow_down
OverviewSet up ToolManagerRead only modeDisable annotation creation/editingDefault annotation propertiesAnnotation propertiesEventsOverride annotation handlingShow and hide existing annotationsUndo and redoRealtime collaboration

Advanced customization

keyboard_arrow_down
Add a custom view to a pageCreate a custom toolPage coloring modePage fit modePage layout mode

Conversion

keyboard_arrow_down
Convert documents to PDFConvert HTML to PDF

Search

keyboard_arrow_down

Other Frameworks

keyboard_arrow_down
XamarinReact Native

Advanced topics

keyboard_arrow_down
Understand coordinatesDocument savingDocument lockingGenerate page thumbnailsTool class hierarchy

FAQ

keyboard_arrow_down
System RequirementsRun project in Android StudioRun project with source codePDFTron full vs. standardLocalizationIcon cheat sheetReduce size of APKEnable multidexOut of memory when rotating device multiple timesReduce memory consumptionDetachCurrentThread 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