Some test text!

menu
Customizekeyboard_arrow_down

Customize the new Viewer UI

Customize the new Viewer UI

linkCustomize the theme

The theme of PdfViewCtrlTabHostFragment2 can be set by calling the following method when creating the fragment using ViewerBuilder2:

// Add a viewer fragment to the layout container in the specified 
// activity, and returns the added fragment
public PdfViewCtrlTabHostFragment2 addViewerFragment(
        int fragmentContainer,
        AppCompatActivity activity,
        Android.Net.Uri fileUri,
        String password,
        int customTheme)
{

    // Create the viewer fragment
    PdfViewCtrlTabHostFragment2 fragment =
            ViewerBuilder2.WithUri(fileUri, password)
                    // Add custom theme here
                    .UsingTheme(customTheme)
                    .Build(activity) as PdfViewCtrlTabHostFragment2;

    // Add the fragment to the layout fragment container
    activity.SupportFragmentManager.BeginTransaction()
            .Replace(fragmentContainer, fragment)
            .Commit();

    return fragment;
}

Theme supplied to ViewerBuilder2.usingTheme(int) is recommended to extend PDFTronAppThemeBase. If you cannot extend PDFTronAppThemeBase and is extending an AppCompat theme, then you will need to define custom theme attributes for the theme to work properly. Custom attributes are listed in the table below. PDFTronAppThemeBase contains a number of attributes which can be used to define the style for certain UI components. A full list of theme attributes can be found below:

AttributeDescription
pt_toolbar_themeUsed to style the options menu toolbar. See ToolbarTheme.
pt_toolbar_popup_styleUsed to style the popup menu in the toolbar. See ToolbarPopupTheme.
pt_toolbar_styleUsed to style the options menu toolbar background. See ToolbarStyle.
pt_bottom_bar_styleUsed to style the bottom navigation bar. See PTBottomBarTheme.
pt_preset_bar_styleUsed to style the annotation preset bar. See PTPresetBarTheme.
pt_annotation_toolbar_styleUsed to style the annotation toolbar. See PTAnnotationToolbarTheme.
pt_toolbar_switcher_dialog_styleUsed to style the toolbar switcher popup dialog. See PTToolbarSwitcherDialogTheme.
pt_toolbar_switcher_button_styleUsed to style the toolbar switcher menu button. See PTToolbarSwitcherButtonTheme .
pt_document_slider_styleUsed to style the page slider. See DocumentSliderStyle.
pt_pdf_tab_layout_styleUsed to style the document tabs. See PdfTabLayoutStyle.
pt_stamp_tab_layout_styleUsed to style the stamp dialog tab layout. See StampTabLayoutStyle.
custom_bookmarks_tab_layoutUsed to style the outline/user bookmark/annotation list dialog. See BookmarksTabLayoutStyle.
pt_floating_nav_styleUsed to style the floating action buttons. See DefaultFloatingButtonNavStyle.
pt_sound_dialog_styleUsed to style the sound annotation dialog. See SoundDialogStyle
pt_stamp_tab_layout_styleUsed to style the stamp dialog tab layout. See StampTabLayoutStyle.

A full list of attributes can be found in the styles.xml file in the PDFTron Android SDK Tools package.

linkCustomizing the default annotation toolbars

The built-in default toolbars can be customized using the ViewerConfig and ToolManagerBuilder classes. To hide a specific toolbar, call ViewerConfig.Builder.hideToolbars(String[]) with the toolbar's tag. For example to hide the annotate toolbar:

ViewerConfig.Builder builder = new ViewerConfig.Builder()
        .HideToolbars(
                new String[]{
                        DefaultToolbars.TagAnnotateToolbar
                }
        );

linkHide annotation toolbar buttons

To hide certain tool buttons, you can disable tool modes using ToolManagerBuilder as described in this guide.

linkCustomize the options toolbar

The options toolbar can be customized using a similar method as described in this guide, however the ViewerBuilder2 class will be used instead of ViewerBuilder.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close