Some test text!

keyboard_arrow_down

Get started

Download PDFTron SDK
play_arrow

Quick start - view a document

Integrate with NuGetIntegrate manuallyRun samplesAdd license keyUpdate to latest version
keyboard_arrow_down

Xamarin.Forms

keyboard_arrow_down

Fundamentals

Java binding (Android)Objective-C binding (iOS)Code sharingDocument lockingDocument saving
keyboard_arrow_down

FAQ

System requirementsPDFTron full vs. standardReduce size of APK
keyboard_arrow_down

Document Viewer

play_arrow

Xamarin.Android

OverviewShow a document in an ActivityShow a document in a FragmentViewer configurationToolManager configurationDay and Night themes
play_arrow

Xamarin.iOS

Show a document in a ViewControllerShow documents in a tabbed ViewControllerOpen from online URL
keyboard_arrow_down

Document Viewer components

Overview
play_arrow

PDFViewCtrl

Xamarin.AndroidXamarin.iOS
play_arrow

Reflow

Quick menuCustomize quick menu
play_arrow

Annotation toolbar

play_arrow

Annotation style editor

play_arrow

Page slider

Xamarin.AndroidXamarin.iOS
play_arrow

List container

Xamarin.AndroidXamarin.iOS
play_arrow

Annotation list

play_arrow

Document outline

play_arrow

User bookmark list

play_arrow

Thumbnail browser

Add pages dialogCrop pages dialogRotate pages dialogView mode dialog
keyboard_arrow_down

Annotation and collaboration

OverviewToolManager setupRead only mode
play_arrow

Disable annotation creation and editing

Xamarin.AndroidXamarin.iOS
play_arrow

Default annotation properties

play_arrow

Change tool mode

Xamarin.AndroidXamarin.iOS
play_arrow

Events

Xamarin.AndroidXamarin.iOS
play_arrow

Override annotation handling

Show and hide existing annotationsRealtime collaboration
keyboard_arrow_down

Advanced customization

play_arrow

Add a custom view to a page

Xamarin.AndroidXamarin.iOSCreate a custom toolPage coloring modePage fit modePage layout modeScrolling direction
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 thumbnails
keyboard_arrow_down

Troubleshooting

keyboard_arrow_down

Reference

keyboard_arrow_down

PDF Processing API

Customize quick menukeyboard_arrow_down

Customize quick menu

In this document
chevron_rightOverride menu resources
chevron_rightQuick menu resources
chevron_rightCreate your own quick menu
chevron_rightClick events
chevron_rightQuick menu style
chevron_rightIcon style
chevron_rightButton style
chevron_rightBackground
chevron_rightDivider
This tutorial only applies to Xamarin.Android.

It is possible to customize the quick menu by overriding the default menu resource XML files, or by creating your own.

linkOverride menu resources

In this tutorial you will customize the quick menu for the Pan tool by overriding the default menu resource XML file in the PDFTron SDK.

  1. Create a menu resource XML file called pan.xml in your project's Resources/menu folder. This pan.xml file will automatically be used instead of the default one in the tools package. To override other quick menus, refer to the [table below] (#quick-menu-resources) to determine the name of the menu resource file.

  2. Add two items to you menu in pan.xml with the id attributes @+id/qm_free_text and @+id/qm_floating_sig:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@+id/qm_free_text"
            android:title="@string/tools_qm_free_text"
            android:icon="@drawable/ic_annotation_freetext_black_24dp" />
        <item android:id="@+id/qm_floating_sig"
            android:title="@string/tools_qm_signature" 
            android:icon="@drawable/ic_annotation_signature_black_24dp" />
    </menu>

    Here we use the ids @+id/qm_free_text and @+id/qm_floating_sig to override the Free Text and Signature menu items.

    You can also create your own menu items by providing a unique id, or by overriding our other menu items using the menu ids defined in the tools package. You can learn more about handling custom menu item click events here.

    Now, when you long-press on a blank space, you will see:

linkQuick menu resources

Menu resourceToolTriggered event
panPanLong press on blank space
text_selectTextSelectLong press on text
annot_simple_shapeAnnotEditSingle tap on Square, Circle, Line, Polygon, Polyline, Text
annot_free_textAnnotEditSingle tap on FreeText
annot_linkAnnotEditSingle tap on Link
annot_signatureAnnotEditSingle tap on signature (type: Annot.e_Stamp and custom field: Signature.SIGNATUREANNOTATIONID)
annot_stamperAnnotEditSingle tap on Stamp (type: Annot.e_Stamp and custom field: Stamper.STAMPERANNOTATIONID)
annot_file_attachmentAnnotEditSingle tap on FileAttachment
annot_free_handAnnotEditSingle tap on Ink
annot_generalAnnotEditSingle tap on all other annotation types
annot_edit_text_markupAnnotEditTextMarkupSingle tap on TextMarkup annotations
typeAnnotEditTextMarkupClick quick menu item with id R.id.type
sig_field_imageDigitalSignatureSingle tap on digital image signature
annot_edit_thicknessDigitalSignatureClick quick menu item with id id.thickness
sig_field_pathsDigitalSignatureSingle tap on digital signature, or click on items in quick menu R.menu.annot_edit_thickness

linkCreate your own quick menu

You can use quick menus in a ToolManager as well as in your application logic directly. By the end of this tutorial, you will be able to create your own quick menu.

  1. First, add a menu resource XML file in your project's Resources/menu folder. For example, let's create a file called custom.xml.

    By default, all menu items are placed in the first row of the quick menu. If you want to specify the location of a menu item, enclose the item inside a group with a group id from this list:

Group idLocation in quick menu
@id/qm_first_row_groupFirst row group id: all menu items inside this group will be displayed in the first row of the quick menu.
@id/qm_second_row_groupSecond row group id: all menu items inside this group will be displayed in the second row of the quick menu.
@id/qm_overflow_row_groupOverflow list group id: all menu items inside this group will be displayed in the overflow menu list of the quick menu.
  1. Add the following to custom.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <group android:id="@id/qm_first_row_group">
            <item android:id="@+id/rectangle"
                android:title="@string/tools_qm_rectangle"
                android:icon="@drawable/ic_annotation_square_black_24dp" />
        </group>
        <group android:id="@id/qm_second_row_group">
            <item android:id="@+id/line"
                android:title="@string/annot_line"
                android:icon="@drawable/ic_annotation_line_black_24dp"/>
            <item android:id="@+id/free_text"
                android:title="@string/tools_qm_free_text"
                android:icon="@drawable/ic_annotation_freetext_black_24dp"/>
        </group>
        <group android:id="@id/qm_overflow_row_group">
            <item android:id="@+id/floating_sig"
                android:title="@string/tools_qm_signature"/>
            <item android:id="@+id/link"
                android:title="@string/annot_link"/>
        </group>
    </menu>

    You can also add a sub menu by specifiying it in the menu resource XML. For example, we can add an Oval menu item as a submenu under the Rectangle menu item by changing custom.xml to:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <group android:id="@id/qm_first_row_group">
            <item android:id="@+id/rectangle"
                android:title="@string/tools_qm_rectangle"
                android:icon="@drawable/ic_annotation_square_black_24dp" >
                <!-- Sub menu added to Rectangle menu item -->
                <menu>
                    <group android:id="@id/qm_first_row_group">
                        <item android:id="@+id/oval"
                            android:title="@string/annot_circle"/>
                    </group>
                </menu>
            </item>
        </group>
        <group android:id="@id/qm_second_row_group">
            <item android:id="@+id/line"
                android:title="@string/annot_line"
                android:icon="@drawable/ic_annotation_line_black_24dp"/>
            <item android:id="@+id/free_text"
                android:title="@string/annot_free_text"
                android:icon="@drawable/ic_annotation_freetext_black_24dp"/>
        </group>
        <group android:id="@id/qm_overflow_row_group">
            <item android:id="@+id/floating_sig"
                android:title="@string/tools_qm_signature"/>
            <item android:id="@+id/link"
                android:title="@string/annot_link"/>
        </group>
    </menu>

    For more information on defining an XML menu resource, see Defining a Menu in XML.

  2. After adding the menu resource XML, initialize QuickMenu as follows:

    Alternatively, if you want to customize menu items manually you can call QuickMenu.Inflate to prevent auto-initialization. Then after customizing the items, call QuickMenu.initMenuEntries to apply your changes:

  3. When you want to show the quick menu, set an anchor view that defines where the quick menu should appear by calling QuickMenu.SetAnchor(View), then call :

    The quick menu will automatically adjust its position to either the top or bottom of the anchor view, depending on the space available:

    At this point, you should see the following when the quick menu is shown:

    Without sub menu:

    With sub menu:

linkClick events

Click events from your custom items will not be automatically handled by the PDFTron SDK if the menu item id does not match any of the default ids defined in the tools package (located in the PDFViewCtrlTools\res\menu\ids.xml file). You will have to handle these events as described in this guide or by implementing DismissEvent: