> 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/xamarin/basic-operations/basics/viewer/viewer-configuration-legacy.md).

# Customize a document view controller in Xamarin

Optimize your document viewer with the legacy PTDocumentViewController class guide. Upgrade to PTDocumentController for enhanced viewing experience and new features. Learn how to customize viewer clas

{% hint style="info" %}
**Legacy Viewer**

This guide is for the legacy `PTDocumentViewController` class. This class is no longer being updated. For the best viewing experience and to take advantage of new developments, the `PTDocumentController` should be used. Please see [this guide](/ios/ui-customization/viewer-configuration.md) for information.
{% endhint %}

This article explains how to customize the document viewer classes [`PTDocumentViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentViewController.html) and [`PTTabbedDocumentViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html).

Because the document viewer classes are part of the open source Tools UI framework, it is possible to achieve virtually any required modification. That said, it is usually faster and more convenient to configure the viewers via APIs, which this guide describes.

## PTDocumentViewController

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-9aa75e52b3945609e68304121e477b2dd6625259%2Faa266fa7b632db20aea3f1b1f35efc263386ea13-2366x1948.png?alt=media)

The **image on the left** indicates areas that are controllable via the `PTDocumentViewController`'s API. Information on customizing these is available [directly below](https://docs.apryse.com).

The **image on the right** indicates a number of default buttons that create and present new controls. Information on where to look to customize these presented controls can be found in the [component controls table](https://docs.apryse.com).

### 1: Left bar button item

When presented in a `UINavigationController`, the `PTDocumentViewController`'s left bar button item will display the name of the previous view controller's navigation item's [`title`](https://developer.apple.com/uikit/uinavigationitem/1624965-title/) (or, if set, its [`backBarButtonItem`](https://developer.apple.com/uikit/uinavigationitem/1624958-backbarbuttonitem/)). When presented as a `UINavigationController`'s root controller, the space will be empty.

The `PTDocumentViewController`'s left bar button item can be added or replaced as follows:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
var title = "Apryse";
tabViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(title, UIBarButtonItemStyle.Plain, (sender, e) => {
    // handle bar button item action
});
```

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

### 2: Right bar button items

These buttons, which are contained in the [`rightBarButtonItems`](https://developer.apple.com/uikit/uinavigationitem/1624956-rightbarbuttonitems/) array, are completely customizable. It is possible to

* [Remove (hide) buttons](https://docs.apryse.com)
* [Add buttons](https://docs.apryse.com)
* [Move buttons](https://docs.apryse.com)
* [Change icons](https://docs.apryse.com)

#### Remove buttons

Default buttons can be removed ("hidden") using built-in properties. From left-to-right:

* [`searchButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_SearchButtonHidden)
* [`shareButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_ShareButtonHidden)
* [`viewerSettingsButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_ViewerSettingsButtonHidden)
* [`annotationToolbarButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_AnnotationToolbarButtonHidden)

For example to hide the share and viewer settings buttons:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
documentViewController.ShareButtonHidden = true;
documentViewController.ViewerSettingsButtonHidden = true;
```

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

#### Add buttons

Buttons can be added by accessing the appropriate BarButtonItem array and adding a button:

Adds a button to the top navigation bar:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// add a button to the top bar
var plusButtonTop = new UIBarButtonItem(UIBarButtonSystemItem.Add, (sender, e) =>
{
    Console.WriteLine("button pressed:" + sender);
});

var currentItems = documentViewController.NavigationItem.RightBarButtonItems;
var itemsArray = new List<UIBarButtonItem>(currentItems);
itemsArray.Add(plusButtonTop);

documentViewController.NavigationItem.RightBarButtonItems = itemsArray.ToArray();

// add a button to the right of the page slider
var refreshButtonBottom = new UIBarButtonItem(UIBarButtonSystemItem.Refresh,(sender, e) => 
{
    Console.WriteLine("button pressed:" + sender);
});

currentItems = documentViewController.ThumbnailSliderController.TrailingToolbarItems;
itemsArray = new List<UIBarButtonItem>(currentItems);
itemsArray.Add(refreshButtonBottom);

documentViewController.ThumbnailSliderController.TrailingToolbarItems = itemsArray.ToArray();
```

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

#### Move buttons

The default buttons are all accessible via properties, making it easy to rearrange or move them. The following code swaps the position of the search button and navigation lists button:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
var rightItems = documentViewController.NavigationItem.RightBarButtonItems;
var rightItemsList = new List<UIBarButtonItem>(rightItems);
rightItemsList.Remove(documentViewController.SearchButtonItem);
rightItemsList.Add(documentViewController.NavigationListsButtonItem);

var bottomRightItems = documentViewController.ThumbnailSliderController.TrailingToolbarItems;
var bottomRightItemsList = new List<UIBarButtonItem>(bottomRightItems);
bottomRightItemsList.Remove(documentViewController.NavigationListsButtonItem);
bottomRightItemsList.Add(documentViewController.SearchButtonItem);

documentViewController.NavigationItem.RightBarButtonItems = rightItemsList.ToArray();
documentViewController.ThumbnailSliderController.TrailingToolbarItems = bottomRightItemsList.ToArray();
```

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

#### Change icons

The icons of existing buttons may be changed by creating new `UIBarButtonItems` that have the same target and action as an existing item, and replacing the existing item with the new item:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// new share UIBarButtonItem
var newShareItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, documentViewController.ShareButtonItem.Target, documentViewController.ShareButtonItem.Action);
var rightItems = documentViewController.NavigationItem.RightBarButtonItems;
var rightItemsList = new List<UIBarButtonItem>(rightItems);
var index = rightItemsList.IndexOf(documentViewController.ShareButtonItem);
rightItemsList.Remove(documentViewController.ShareButtonItem);
rightItemsList.Insert(index, newShareItem);

// new search UIBarButtonItem
var newSearchItem = new UIBarButtonItem(UIBarButtonSystemItem.Search, documentViewController.SearchButtonItem.Target, documentViewController.SearchButtonItem.Action);
index = rightItemsList.IndexOf(documentViewController.SearchButtonItem);
rightItemsList.Remove(documentViewController.SearchButtonItem);
rightItemsList.Insert(index, newSearchItem);

// update the icons
documentViewController.NavigationItem.RightBarButtonItems = rightItemsList.ToArray();
```

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

### 3: PDFViewCtrl

The `PTPDFViewCtrl` is a `UIView` that displays the PDF. It is customizable via is properties/methods and delegate methods.

For an overview see the [PTPDFViewCtrl Guide ](/ios/basic-operations/basics/viewer/pdfviewctrl.md#customize-a-ptpdfviewctrl), or the detailed [API documentation](https://sdk.apryse.com/api/ios/Classes/PTPDFViewCtrl.html).

Note that all PDF "interaction" (annotations, form filling, text selection, link following, etc.) is supplementary to the PDFViewCtrl, and is implemented in the open source [`tools.framework`](/ios/annotation/overview.md).

### 4: Page number indicator

The page indicator can be enabled/disabled via the [`pageIndicatorEnabled`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_PageIndicatorEnabled) property.

### 5: Thumbnail slider controller

The thumbnail slider can be enabled/disabled via the [`bottomToolbarEnabled`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_BottomToolbarEnabled) property.

The default buttons presented to the right and left of the slider are easily hidden through the convenience properties [`thumbnailBrowserButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_ThumbnailBrowserButtonHidden) and [`navigationListsButtonHidden`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentBaseViewController.html#pdftron_PDF_Controls_PTDocumentBaseViewController_NavigationListsButtonHidden) on the `PTDocumentViewController`:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
documentViewController.ThumbnailBrowserButtonHidden = true;
```

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

### 6-12: Controls Presented by a PTDocumentViewController

To customize the controls that are presented by the `PTDocumentViewController`'s default buttons, please see the corresponding guide or API:

| Image number | Control                                                                                                                                    |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| 6            | [`PTTextSearchViewController`](/xamarin/guides/ios/search/text-search.md#ui-component)                                                     |
| 7            | [`UIDocumentInteractionController`](https://developer.apple.com/uikit/uidocumentinteractioncontroller/)                                    |
| 8            | [`PTSettingsViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTSettingsViewController.html)           |
| 9            | [`PTAnnotationToolbar`](/xamarin/annotation/annotation-toolbar.md#ios)                                                                     |
| 10           | [`PTPageIndicatorViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTPageIndicatorViewController.html) |
| 11           | [`PTThumbnailSliderViewController`](/xamarin/ui-customization/thumbnail-slider.md#ios)                                                     |
| 12           | [`PTNavigationListsViewController`](/xamarin/ui-customization/list-container.md#ios)                                                       |

## PTTabbedDocumentViewController

The [tabbed document view controller](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html) displays a collection of [document viewer controllers](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentViewController.html) in tabs.

### Tab Settings

Tabs can be disabled using the [`TabsEnabled`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html#pdftron_PDF_Controls_PTTabbedDocumentViewController_TabsEnabled) property, and the maximum number of allowed tabs can be set using [`MaximumTabCount`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html#pdftron_PDF_Controls_PTTabbedDocumentViewController_MaximumTabCount).

### Access to child PTDocumentViewControllers

The current document view controller can be accessed via [`SelectedViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html), and others via [`documentViewControllerAtIndex`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html)

To configure a document view controller before it is displayed, conform to and implement the [`PTTabbedDocumentViewControllerDelegate`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewControllerDelegate.html) method [`willAddDocumentViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewControllerDelegate.html). Note that it **is** permissible to assign the internal `PTDocumentViewController`'s delegate to an external object.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
tabbedDocumentViewController.WillAddDocumentViewController += (sender, e) =>
{
    // do something with e.DocumentViewController
};
```

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

### Summary

| API                                                                                                                                                                                               | Functionality                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [`TabsEnabled`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html#pdftron_PDF_Controls_PTTabbedDocumentViewController_TabsEnabled)         | Enables/disables tabs.                                                |
| [`MaximumTabCount`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html#pdftron_PDF_Controls_PTTabbedDocumentViewController_MaximumTabCount) | Controls the maximum number of concurrent tabs.                       |
| [`SelectedViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html)                                                              | The current `PTDocumentViewController`.                               |
| [`documentViewControllerAtIndex`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html)                                                       | The `PTDocumentViewController` at the given index.                    |
| [`willAddDocumentViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewControllerDelegate.html)                                               | Access to a `PTDocumentViewController` that is about to be displayed. |


---

# 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/xamarin/basic-operations/basics/viewer/viewer-configuration-legacy.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.
