Some test text!

menu
search

Customize the document viewer

This tutorial only applies to Xamarin.Android.

DocumentActivity and PdfViewCtrlTabHostFragment are highly configurable and can be easily customized using our document viewer configuration classes. UI components can be hidden and functionality can be disabled by initializing the document viewer using ViewerConfig.Builder.

For further customization, PDFViewCtrlConfig allows you to initialize PDFViewCtrl with low-level viewer settings, and ToolManagerBuilder allows you to customize annotation functionality in ToolManager.

linkConfigure Document Viewer

DocumentActivity and PdfViewCtrlTabHostFragment can be initialized using ViewerConfig, which can be created with a ViewerConfig.Builder object.

For example:

// Customize settings in ViewerConfig
var config = new ViewerConfig.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();
    
// Initialize your document viewer with a 
// a ViewerConfig when you open a document
DocumentActivity.OpenDocument(context, localFilePath, config)

A full list of settings for ViewerConfig.Builder can be found in the API documentation.

linkConfigure PDFViewCtrl

PDFViewCtrl specific functionality can be configured using PDFViewCtrlConfig. You can then pass the configuration to ViewerConfig to initialize PDFViewCtrl in your document viewer with your specific settings.

For example:

// Customize settings in PDFViewCtrlConfig
var pdfViewCtrlConfig = PDFViewCtrlConfig.GetDefaultConfig(this)
    .SetClientBackgroundColor(Android.Graphics.Color.Yellow)
    .SetClientBackgroundColorDark(Android.Graphics.Color.Blue)
    .SetHighlightFields(true)
    .SetImageSmoothing(true)
    .SetUrlExtraction(true)
    .SetMaintainZoomEnabled(true);

// Pass the the PDFViewCtrlConfig into your ViewerConfig
// so that it can be used to initialize PDFViewCtrl 
// in your document viewer
var builder = new ViewerConfig.Builder();
var config = builder
    .PdfViewCtrlConfig(pdfViewCtrlConfig)
    // ...
    .Build();

A full list of settings for PDFViewCtrlConfig can be found in the API documentation.

linkConfigure ToolManager

Annotation tool functionality can be configured using ToolManagerBuilder, such as hiding/disabling specific annotation creation tools or disabling the quick menu. You can then pass the configuration to ViewerConfig to initialize ToolManager in your document viewer with your specific settings. Alternatively, you can also modify the style resource for ToolManager directly, and pass it to ViewerConfig.

  • Configure ToolManager by setting ToolManagerBuilder to an instance of ViewerConfig:

    // Customize settings in ToolManagerBuilder
    var toolManagerBuilder = ToolManagerBuilder.From()
        .SetEditFreeTextOnTap(false)
        .SetDisableQuickMenu(true);
    
    // Pass the the ToolManagerBuilder into your ViewerConfig
    // so that it can be used to initialize ToolManager 
    // in your document viewer
    var builder = new ViewerConfig.Builder();
    var config = builder
        .ToolManagerBuilder(toolManagerBuilder)
        // ...
        .Build();

    A full list of settings for ToolManagerBuilder can be found in the API documentation.

  • Configure ToolManager by setting an XML style resource:

    // Pass the XML style resource R.style.MyToolManager to ViewerConfig
    var builder = new ViewerConfig.Builder();
    var config = builder
        .ToolManagerBuilderStyleRes(Resource.Style.MyToolManager)
        // ...
        .Build();

    Defining a style for ToolManager is explained in detail in the ToolManager configuration guide.

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.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn More
close