Android: show PRESET area at ToolBar with PdfViewCtrl in a ToolBar AnnotationToolbarComponent

Product: PDFTron Android

Product Version: 9.3.1

Please give a brief summary of your issue:
show PRESET area in a ToolBar with PdfViewCtrl and AnnotationToolbarComponent

Please describe your issue and provide steps to reproduce it:
Hi! I want to show the preset options in a ToolBar created with AnnotationToolbarComponent in an Activity that shows the document with a PdfCtrlView controller. I would like to get this:

My code is:

// First find our container view group
            FrameLayout mToolbarContainer = new FrameLayout(mContext);
            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            params.addRule(RelativeLayout.ABOVE, BOTTOM_BAR_ID);
            addView(mToolbarContainer, params);

            // Then setup ToolManager and related ViewModels with AnnotationToolbarComponent
            // Remember to initialize your ToolManager before calling below
            FragmentActivity activity = (FragmentActivity) getActivity(mContext);
            ViewModelProvider vmProvider = new ViewModelProvider(activity);
            ToolManagerViewModel toolManagerVm = vmProvider.get(ToolManagerViewModel.class);
            PresetBarViewModel presetVm = vmProvider.get(PresetBarViewModel.class);
            AnnotationToolbarViewModel annotToolbarVm = vmProvider.get(AnnotationToolbarViewModel.class);

            // Create our UI component for the annotation toolbar
            mAnnotationToolbarComponent = new AnnotationToolbarComponent(
                    AnnotationToolbarBuilder.withTag("Custom Toolbar")
                            // Add some pre-defined tools that will be handled internally using ToolManager
                            .addToolButton(ToolbarButtonType.SQUARE, 100)
                            .addToolButton(ToolbarButtonType.INK, 102)
                            .addToolButton(ToolbarButtonType.FREE_HIGHLIGHT, 103)
                            .addToolButton(ToolbarButtonType.ERASER, 104)
                            // We can also add a custom button to handle ourselves, for example here
                            // we have added a "favorites" button that contains a star icon
                            // .addCustomButton(R.string.favorites, R.drawable.annotation_note_icon_star_fill, 105)
                            .addToolStickyButton(ToolbarButtonType.UNDO, 106)
                            .addToolStickyButton(ToolbarButtonType.REDO, 107)


Hi @jbonilla

Unfortunately it is not clear to us what you’re trying to achieve with this sample code.

  • Could you please provide a screenshot of what you’re trying to accomplish?
  • Could you provide a high level use case what you’re trying to achieve?


Hi @ama , thanks for your reply! What I am looking for is for the preset toolbar to appear everytime the user selects an annotation tool. For example, if you select the INK_CREATE annotation tool, the preset zone appears like this:

I don’t care if it’s in the left zone of the bar or in the right zone (sticky buttons zone)

Thanks once again.


Hi @jbonilla

We suggest using the TabletAnnotationToolbarComponent to achieve what you’re looking for by having the preset bar component always show up. Portrait phone layouts may appear a little unusual with the tablet annotation toolbar component.

You can refer to our PdfViewCtrlViewer sample which provides an example of how to add the preset bar to the annotation toolbar component: