> 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/page-manipulation/thumbnail-browser.md).

# Thumbnail browser

Learn how to manipulate pages with a thumbnail browser in Xamarin.Android. Preview, add, remove, rearrange, and export pages easily. Implement dialog callbacks for a seamless user experience. Click to

You can get previews of a document's pages.

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

## Manipulate pages with thumbnail browser in Xamarin.Android

{% hint style="info" %}
This tutorial only applies to Xamarin.Android. See [Xamarin.iOS equivalent here](#manipulate-pages-with-thumbnail-browser-in-xamarinios).
{% endhint %}

The [`ThumbnailsViewFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.ThumbnailsViewFragment.html) class allows users to manipuate pages of a document including add, remove, re-arrange, rotate and duplicate pages. Users are also able to undo/redo page manipulations.

![Host Fragment](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-b2be354b1079b2634036eb904006d82e81becb52%2Fb25f5232f4421874bfbbb81868578fbc4b041d7b-1080x2220.gif?alt=media)

## Show page thumbnails dialog

To show a page thumbnails dialog in your activity, create a new instance of [`ThumbnailsViewFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.ThumbnailsViewFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html):

{% code lineNumbers="true" %}

```csharp
var thumbDialog = ThumbnailsViewFragment.NewInstance();
thumbDialog.SetPdfViewCtrl(mPdfViewCtrl);
thumbDialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
thumbDialog.Show(this.SupportFragmentManager, "thumbnails_dialog");
```

{% endcode %}

If you want to specify that the document is read-only you can use `newInstance(boolean)`:

{% code lineNumbers="true" %}

```csharp
var thumbDialog = ThumbnailsViewFragment.NewInstance(true);
```

{% endcode %}

## Export pages

If you would like to allow users to export a subset of pages from the document, you should implement `OnExportThumbnailsListener` interface by providing implementation for exporting pages:

{% code lineNumbers="true" %}

```csharp
thumbDialog.ExportThumbnails += (sender, e) =>
{
    // Implementation for exporting given pages.
};
```

{% endcode %}

If you set `OnExportThumbnailsListener`, the "Export" menu item will show up in the overflow menu when at least one page is selected.

![Export](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-584450b48e0a2488435ada3d1b42beca2a46b586%2F3b6387fd4451f6687b00bb42908f768857a01ead-1080x2160.png?alt=media)

## Dialog callbacks

If you want to be notified when the thumbnails view dialog fragment is dismissed, implement `OnThumbnailsViewDialogDismissListener` interface. Also, if you want to be notified when the user attempts to edit pages while the document is read only you should implement `OnThumbnailsEditAttemptWhileReadOnlyListener` interface:

{% code lineNumbers="true" %}

```csharp
thumbDialog.ThumbnailsViewDialogDismiss += (sender, e) =>
{
    // Handle viewer when the thumbnails view dialog is dismissed.
};
thumbDialog.ThumbnailsEditAttemptWhileReadOnly += (sender, e) =>
{
    // Show message when user attempts to edit pages of a read only document.
};
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}

## Manipulate pages with thumbnail browser in Xamarin.iOS

{% hint style="info" %}
This tutorial only applies to Xamarin.iOS. See [Xamarin.Android equivalent here](#manipulate-pages-with-thumbnail-browser-in-xamarinandroid).
{% endhint %}

The [`PTThumbnailsViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailsViewController.html) class allows users to view and navigate the pages of a [`PTPDFViewCtrl`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.PDFViewCtrl.html) as well as re-arrange and remove pages.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-bd3f2685e1a3aa7ffb4ba66016c2e6e44f823017%2F99590c9303b32217e465514f954c54dcd4232733-1242x2208.png?alt=media)

The page thumbnails control is part of the Tools library, so make sure you have [added the Tools library to your project](/xamarin/ui-customization/setup.md).

## Show a page thumbnails view controller

To create a new page thumbnails view controller instance and display it from another view controller, supply a `PTPDFViewCtrl` instance to the `PTThumbnailsViewController` designated initializer:

{% code lineNumbers="true" %}

```csharp
var thumbnailsViewController = new pdftron.PDF.Controls.PTThumbnailsViewController(mPdfViewCtrl);
var navController = new UINavigationController(thumbnailsViewController);
this.PresentViewController(navController, true, null);
```

{% endcode %}

{% hint style="info" %}
The thumbnails view controller does not create its own top navigation bar, so it must be pushed onto a navigation controller's stack in order for the top navigation bar and 'Edit' button to be shown.
{% endhint %}

## Populate the view controller with thumbnail images

The thumbnail images shown in the thumbnails view controller are generated by the `GetThumbAsync:` method of the `PTPDFViewCtrl` class. When ready, the thumbnail images are provided to the `pdfviewCtrl`'s delegate via the `GotThumbAsync:thumbImage:` method.

In your class adopting the `PTPDFViewCtrlDelegate` protocol (usually the same view controller presenting the thumbnails view controller), add the following:

{% code lineNumbers="true" %}

```csharp
mPdfViewCtrl.GotThumbAsync += (sender, e) =>
{
    if (e.Image == null)
    {
        return;
    }
    if (this.thumbnailsViewController != null && this.thumbnailsViewController.PresentingViewController != null)
    {
        this.thumbnailsViewController.SetThumbnail(e.Image, e.Page_num);
    }
};
```

{% endcode %}

## Interact with the view controller

Pages can be re-arranged and removed in edit-mode, which is activated by the 'Edit' button in the navigation bar. Long-pressing and dragging allows the user to move a page to a different location in the same document, and tapping one or more documents selects them for removal with the trash can icon. The user is prompted for confirmation before any pages are permanently removed.
{% 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/page-manipulation/thumbnail-browser.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.
