> 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/page-manipulation/thumbnails-view-a.md).

# Using thumbnail browser to manipulate PDFs in Android

Manipulate, export, and customize PDF pages with ThumbnailsViewFragment. Learn how to add, remove, rearrange, and more. Enhance your document viewing experience now! The Apryse Android SDK streamlines

The [`ThumbnailsViewFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/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.

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%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/android/javadoc/reference/com/pdftron/pdf/controls/ThumbnailsViewFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html):

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

```java
private PDFViewCtrl mPdfViewCtrl;
// ...
public void showThumbnailsFragment(FragmentManager fragmentManager) {
    ThumbnailsViewFragment fragment = ThumbnailsViewFragment.newInstance();
    fragment.setPdfViewCtrl(mPdfViewCtrl);
    // Show the dialog
    fragment.show(fragmentManager, "thumbnails_view_dialog");
}
```

{% endcode %}
{% endtab %}

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

```kotlin
private var mPdfViewCtrl: PDFViewCtrl? = null
// ...
fun showThumbnailsFragment(fragmentManager: FragmentManager) {
    val fragment = ThumbnailsViewFragment.newInstance()
    fragment.setPdfViewCtrl(mPdfViewCtrl!!)
    // Show the dialog
    fragment.show(fragmentManager, "thumbnails_view_dialog")
}
```

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

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

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

```java
ThumbnailsViewFragment fragment = ThumbnailsViewFragment.newInstance(true);
```

{% endcode %}
{% endtab %}

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

```kotlin
val fragment = ThumbnailsViewFragment.newInstance(true)
```

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

## 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:

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

```java
fragment.setOnExportThumbnailsListener(new ThumbnailsViewFragment.OnExportThumbnailsListener() {
    @Override
    public void onExportThumbnails(SparseBooleanArray pageNums) {
        // Implementation for exporting given pages.
    }
});
```

{% endcode %}
{% endtab %}

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

```kotlin
fragment.setOnExportThumbnailsListener {
    // Implementation for exporting given pages.
}
```

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

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

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-d98f6371d28779827fe3922bfef59bcf0e10172f%2F27a1c3268ecd4bd3414fcac62d4851246337cfdb-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:

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

```java
fragment.setOnThumbnailsViewDialogDismissListener(new ThumbnailsViewFragment.OnThumbnailsViewDialogDismissListener() {
    @Override
    public void onThumbnailsViewDialogDismiss(int pageNum, boolean docPagesModified) {
        // Handle viewer when the thumbnails view dialog is dismissed.
        // For example, update the page numbers etc.
    }
});
fragment.setOnThumbnailsEditAttemptWhileReadOnlyListener(new ThumbnailsViewFragment.OnThumbnailsEditAttemptWhileReadOnlyListener() {
    @Override
    public void onThumbnailsEditAttemptWhileReadOnly() {
        // Show message when user attempts to edit pages of a read only document.
        Toast.makeText(activity, "Read-Only document", Toast.LENGTH_SHORT).show();
    }
});
```

{% endcode %}
{% endtab %}

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

```kotlin
fragment.setOnThumbnailsViewDialogDismissListener { pageNum, docPagesModified ->
    // Handle viewer when the thumbnails view dialog is dismissed.
    // For example, update the page numbers etc.
}
fragment.setOnThumbnailsEditAttemptWhileReadOnlyListener {
    // Show message when user attempts to edit pages of a read only document.
    Toast.makeText(activity, "Read-Only document", Toast.LENGTH_SHORT).show()
}
```

{% 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/page-manipulation/thumbnails-view-a.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.
