> 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/viewer/new-ui-migration-x.md).

# Migrate to the New Viewer UI

Learn how to easily migrate to the new Viewer UI in Xamarin.Android and Xamarin.iOS with a few simple steps. Update your libraries, references, and themes for a seamless transition. The Apryse Xamarin

{% tabs %}
{% tab title="Android" %}

## Migrate to the New Viewer UI in Xamarin.Android

If you have integrated the document viewer previously in your app (i.e. [`DocumentActivity`](/xamarin/guides/android/basics/open.md#activity) or [`PdfViewCtrlTabHostFragment`](/xamarin/guides/android/basics/open.md#fragment)), you can easily migrate to use the new UI with a couple of simple steps.

## Prerequisites

* Updated Apryse libraries to version 8.0.0 (see [changelog](/xamarin/changelogs/version-8/v8-0-0.md) for more info)

## Migrate PdfViewCtrlTabHostFragment

1. Update all references to `ViewerBuilder` to `ViewerBuilder2`. This new builder will create the new viewer fragment [`PdfViewCtrlTabHostFragment2`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.PdfViewCtrlTabHostFragment2.html), which contains the new UI.
2. Update all references to `PdfViewCtrlTabHostFragment` to `PdfViewCtrlTabHostFragment2` in your project.
3. Update all references to `PdfViewCtrlTabFragment` to [`PdfViewCtrlTabFragment2`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.PdfViewCtrlTabFragment2.html) in your project.
4. (Optional) If you have defined the `CustomAppTheme` style to customize your theme, you will need to change this style to extend `PDFTronAppTheme` and pass it into `ViewerBuilder2` as described in our customize viewer theme guide.

## Migrate DocumentActivity

1. Remove any calls to `DocumentActivity.openDocument(...)`.
2. Then launch the activity using `DocumentActivity.IntentBuilder` as described in this guide.
3. If you have defined the `CustomAppTheme` style to customize your theme, you will need to change this style to extend `PDFTronAppTheme`.
   {% endtab %}

{% tab title="iOS" %}

## Migrate to the New Viewer UI in Xamarin.iOS

{% hint style="info" %}
\*\*To learn more about the new UI, please see the new UI overview \*\*
{% endhint %}

In [version 8.0.0](/ios/changelogs/version-8/v8-0-0-76251.md), we introduced a new version of the main viewing component. The new class, `PTDocumentController`, is a **near drop-in replacement** for the old [`PTDocumentViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTDocumentViewController.html).

The new UI's API is almost entirely additive, so migrating will in many cases be a case of changing only the class name of the instantiated view controller. If you have implemented delegate methods or accessed a select few APIs, some other code changes will need to be made, as explained below.

### If using `PTDocumentViewController`

* To update: Update all references of `PTDocumentViewController` to `PTDocumentController`.

**Delegate methods**

The class' delegate type has been changed from `PTDocumentViewControllerDelegate` to `PTDocumentControllerDelegate`.

Required change: If you have implemented delegate methods, must update the protocol you implement and the method signatures:

1. Change the conforming delegate from `PTDocumentViewControllerDelegate` to `PTDocumentControllerDelegate`.
2. Change the delegate methods to reference the `PTDocumentController`, both in method name and parameter type, eg:

is now

### If using `PTTabbedDocumentViewController`

As of version 8.0.2, the `PTTabbedDocumentViewController` will by default create tabs which host instances of `PTDocumentController` rather than legacy `PTDocumentViewController` objects. No changes to accomplish this are needed on your part.

(To revert to the old legacy UI, set the `viewControllerClass` property of the tabbed document view controller to `PTDocumentViewController`).

The `PTTabbedDocumentViewController`'s property types (e.g. `selectedViewController`) and method signatures (e.g. [`documentViewControllerAtIndex:`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewController.html)) have changed to reference the `PTDocumentBaseViewController` abstract base class, from which both the `PTDocumentController` and legacy `PTDocumentViewController` inherit.

* Required change: In Objective-C be careful to reference the correct class type for your project. In Swift the compiler should guide you in making the necessary changes.

**Delegate methods**

The type of the `documentViewController` parameter of the [`tabbedDocumentViewController:willAddDocumentViewController:`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTabbedDocumentViewControllerDelegate.html) delegate method has changed from `PTDocumentViewController` to the abstract base class `PTDocumentBaseViewController`.

* Required change: You must match the parameter type in your implementation of the `PTTabbedDocumentViewControllerDelegate` protocol. In Swift if the parameter type in your implementation does not match the type declared in the protocol then your implementation of the method will not be called.

## Update API-based customizations

The table below lists APIs that have changed.

### Properties

Most properties operate as before. These are the ones that have been removed, and how to accomplish the same thing with a `PTDocumentController`.

| Removed `PTDocumentViewController` properties | How to achieve the same functionality with a `PTDocumentController`.                                                                                                                                                                                                                          |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `freehandButtonHidden`                        | One-touch access to freehand annotations is now found in the toolbar. It (and any other tool's button) can be hidden as described in the customize guide.                                                                                                                                     |
| `annotationToolbarButtonHidden`               | The visibility of the toolbar is now controlled via the toolbar switcher. The switcher can be hidden as described in the customize guide.                                                                                                                                                     |
| `freehandButtonItem`                          | A freehand button no longer exists by default in the the navigation items, but one can be added described in the customize guide.                                                                                                                                                             |
| `annotationButtonItem`                        | The toolbar's visibility is now controlled by a `PTAnnotationModeIndicatorView`.                                                                                                                                                                                                              |
| `undoButtonItem`                              | This property is now part of `PTAnnotationModeManager`.                                                                                                                                                                                                                                       |
| `redoButtonItem`                              | This property is now part of `PTAnnotationModeManager`.                                                                                                                                                                                                                                       |
| `annotationToolbar`                           | The customize guide shows how to programmatically customize the new annotation toolbar. The old annotation toolbar class, [`PTAnnotationToolbar`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTAnnotationToolbar.html), is still available if your app requires it. |
| `annotationToolbarHidden`                     | The customize guide shows how to hide and show the new annotation toolbar.                                                                                                                                                                                                                    |

### Annotation toolbar

The [`PTAnnotationToolbar`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTAnnotationToolbar.html) is no longer used, as the new classes are far more versatile and customizable. The old class is available for direct integration if your app requires it.
{% 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/xamarin/viewer/new-ui-migration-x.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.
