Configuring DocumentActivity and PdfViewCtrlTabHostFragment

Both DocumentActivity and PdfViewCtrlTabHostFragment are highly configurable. All UI elements' visibility can be controlled via configuration. As well as PDFViewCtrl configuration and ToolManager configuration.

Default DocumentActivity/PdfViewCtrlTabHostFragment configuration can be modified via ViewerConfig builder.

For example:

ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
    .fullscreenModeEnabled(true)
    .multiTabEnabled(true)
    .documentEditingEnabled(true)
    .longPressQuickMenuEnabled(true)
    .showPageNumberIndicator(true)
    .showBottomNavBar(true)
    .showThumbnailView(true)
    .showBookmarksView(true)
    .toolbarTitle("My Reader")
    .showSearchView(true)
    .showShareOption(true)
    .showDocumentSettingsOption(true)
    .showAnnotationToolbarOption(true)
    .showOpenFileOption(true)
    .showOpenUrlOption(true)
    .showEditPagesOption(true)
    .showPrintOption(true)
    .showCloseTabOption(true)
    .showAnnotationsList(true)
    .showOutlineList(true)
    .showUserBookmarksList(true)
    .build();

Default configuration of PDFViewCtrl can be modified via PDFViewCtrlConfig class, which can then be passed on to ViewerConfig class.

For example:

PDFViewCtrlConfig pdfViewCtrlConfig = PDFViewCtrlConfig.getDefaultConfig(this)
    .setClientBackgroundColor(Color.YELLOW)
    .setClientBackgroundColorDark(Color.BLUE)
    .setHighlightFields(true)
    .setImageSmoothing(true)
    .setUrlExtraction(true)
    .setMaintainZoomEnabled(true);

ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
    ...
    .pdfViewCtrlConfig(pdfViewCtrlConfig)
    .build();

Default configuration of ToolManager can be modified via a style resource, which can then be passed on to ViewerConfig class. For example:

ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
    ...
    .toolManagerBuilderStyleRes(R.style.MyToolManager)
    .build();

R.style.MyToolManager is explained here: Initialize ToolManager.

Alternatively, you can also configure ToolManager by setting ToolManagerBuilder to an instance of ViewerConfig.

ToolManagerBuilder toolManagerBuilder = ToolManagerBuilder.from(context, R.style.MyToolManager);

ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
    ...
    .setToolManagerBuilder(toolManagerBuilder)
    .build();

Lastly, you can use the config object to create a DocumentActivity or PdfViewCtrlTabHostFragment.html.

For example:

DocumentActivity.openDocument(context, localFilePath, config);