> 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/generate/pdf-thumbnails.md).

# Generate PDF page thumbnails in Android

Enhance PDF viewing experience with Apryse's library. Get a thumbnail preview of all pages in your PDF document using PDFViewCtrl. Learn how to request and cancel thumbnail images efficiently. The Apr

{% hint style="info" %}
Apryse's library provides a page thumbnail dialog which shows thumbnails of all PDF document pages. Fore more information, see [thumbnail browser ](/android/page-manipulation/thumbnails-view-a.md).
{% endhint %}

With [`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html), you can get a thumbnail [`Bitmap`](https://developer.android.com/reference/android/graphics/Bitmap.html) image for each page in a PDF document.

The following example request thumbnail for page 3:

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

```java
pdfViewCtrl.addThumbAsyncListener(new PDFViewCtrl.ThumbAsyncListener() {
    @Override
    public void onThumbReceived(int page, int[] buf, int width, int height) {
        try {
            Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
            bitmap.setPixels(buf, 0, width, 0, 0, width, height);
            // use the bitmap 
        } catch (OutOfMemoryError oom) {
            // error
        }
  }
});

// request thumbnail for page 3
pdfViewCtrl.getThumbAsync(3);
```

{% endcode %}
{% endtab %}

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

```kotlin
pdfViewCtrl.addThumbAsyncListener(object:PDFViewCtrl.ThumbAsyncListener() {
    fun onThumbReceived(page:Int, buf:IntArray, width:Int, height:Int) {
        try {
            val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888).apply { 
                this.setPixels(buf, 0, width, 0, 0, width, height)
            }
        } catch (oom:OutOfMemoryError) {
            // error
        }
    }
})

// request thumbnail for page 3
pdfViewCtrl.getThumbAsync(3)
```

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

where `pdfViewCtrl` is an instance of `PDFViewCtrl`.

{% hint style="info" %}
It is recommended you cancel all thumbnail requests once they are no longer needed. To cancel all thumbnail request, use `PDFViewCtrl.cancelAllThumbRequests()`.
{% endhint %}


---

# 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/generate/pdf-thumbnails.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.
