> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/viewer/fragment-config.md).

# Customize the document viewer in Android

Customize and configure DocumentActivity and PdfViewCtrlTabHostFragment2 easily with our document viewer configuration classes. Hide UI components and disable functionality for a tailored experience.

[DocumentActivity](/android/open-save-document/open.md) and [PdfViewCtrlTabHostFragment2](/android/open-save-document/open.md) 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`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/ViewerConfig.Builder.html).

For further customization, [`PDFViewCtrlConfig`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/PDFViewCtrlConfig.html) allows you to initialize [`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html) with low-level viewer settings, and [`ToolManagerBuilder`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/ToolManagerBuilder.html) allows you to customize annotation functionality in [`ToolManager`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/tools/ToolManager.html).

## Configure Document Viewer

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

**For example:**

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Customize settings in ViewerConfig
ViewerConfig 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);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Customize settings in ViewerConfig
val config = 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)
```

{% endcode %}
{% endtab %}
{% endtabs %}

A full list of settings for `ViewerConfig.Builder` can be found in the [API documentation](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/ViewerConfig.Builder.html).

## Configure PDFViewCtrl

[`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html) specific functionality can be configured using [`PDFViewCtrlConfig`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/PDFViewCtrlConfig.html). You can then pass the configuration to `ViewerConfig` to initialize `PDFViewCtrl` in your document viewer with your specific settings.

**For example:**

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Customize settings in PDFViewCtrlConfig
PDFViewCtrlConfig pdfViewCtrlConfig = PDFViewCtrlConfig.getDefaultConfig(this)
    .setClientBackgroundColor(Color.YELLOW)
    .setClientBackgroundColorDark(Color.BLUE)
    .setHighlightFields(true)
    .setImageSmoothing(true)
    .setUrlExtraction(true)
    .setMaintainZoomEnabled(true);

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

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Customize settings in PDFViewCtrlConfig
val pdfViewCtrlConfig = PDFViewCtrlConfig.getDefaultConfig(this)
    .setClientBackgroundColor(Color.YELLOW)
    .setClientBackgroundColorDark(Color.BLUE)
    .setHighlightFields(true)
    .setImageSmoothing(true)
    .setUrlExtraction(true)
    .setMaintainZoomEnabled(true)

// Pass the PDFViewCtrlConfig into your ViewerConfig
// so that it can be used to initialize PDFViewCtrl 
// in your document viewer
val builder = ViewerConfig.Builder()
val config = builder
  .pdfViewCtrlConfig(pdfViewCtrlConfig)
  // ...
  .build()
```

{% endcode %}
{% endtab %}
{% endtabs %}

A full list of settings for `PDFViewCtrlConfig` can be found in the [API documentation](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/ViewerConfig.Builder.html).

## Configure ToolManager

Annotation tool functionality can be configured using [`ToolManagerBuilder`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/PDFViewCtrlConfig.html), such as hiding/disabling specific annotation creation tools or disabling the quick menu. You can then pass the configuration to `ViewerConfig` to initialize [`ToolManager`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/tools/ToolManager.html) 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`:A full list of settings for `ToolManagerBuilder` can be found in the [API documentation](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/config/ToolManagerBuilder.html).

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Customize settings in ToolManagerBuilder
ToolManagerBuilder toolManagerBuilder = ToolManagerBuilder.from()
    .setEditFreeTextOnTap(false)
    .setDisableQuickMenu(true);

// Pass the ToolManagerBuilder into your ViewerConfig
// so that it can be used to initialize ToolManager
// in your document viewer
ViewerConfig.Builder builder = new ViewerConfig.Builder();
ViewerConfig config = builder
    .toolManagerBuilder(toolManagerBuilder)
    // ...
    .build();
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Customize settings in ToolManagerBuilder
val toolManagerBuilder = ToolManagerBuilder.from()
    .setEditFreeTextOnTap(false)
    .setDisableQuickMenu(true)

// Pass the ToolManagerBuilder into your ViewerConfig
// so that it can be used to initialize ToolManager
// in your document viewer
val builder = ViewerConfig.Builder()
val config = builder
    .toolManagerBuilder(toolManagerBuilder)
    // ...
    .build()
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Configure `ToolManager` by setting an XML style resource:Defining a style for `ToolManager` is explained in detail in the [ToolManager configuration guide ](/android/annotation/toolmanager-config.md).

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
ViewerConfig.Builder builder = new ViewerConfig.Builder();
// Pass the XML style resource R.style.MyToolManager to ViewerConfig
ViewerConfig config = builder
    .toolManagerBuilderStyleRes(R.style.MyToolManager)
    // ...
    .build();
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Pass the XML style resource R.style.MyToolManager to ViewerConfig
val builder = ViewerConfig.Builder()
val config = builder
    .toolManagerBuilderStyleRes(R.style.MyToolManager)
    // ...
    .build()
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/viewer/fragment-config.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
