> 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/web/generate/thumbnail.md).

# Generate PDF page thumbnails using Apryse's Web SDK

Generate PDF page thumbnails on Apryse's Web SDK effortlessly. Customize resolution, size, and annotations with the SDK API for high-quality output. The Apryse Web SDK streamlines secure, serverless d

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#PageManipulation" class="button primary">Package: Page Manipulation</a><a href="https://showcase.apryse.com/create-thumbnail" class="button primary">Live demo</a>
{% endhint %}

Page thumbnails are rendered image representations of the page they are generated from.

The SDK API has the flexibility to alter the resolution or size of the thumbnail output and whether to include annotations or not.

## Create a basic page thumbnail

To create a basic PDF page thumbnail where the result is a HTMLCanvasElement or HTMLImageElement.

`_loadThumbnailAsync_`\_ is deprecated since version 8.3 and removed since version 10.0. Please use *`_loadThumbnail_`* instead.\_

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { documentViewer } = instance.Core;
    documentViewer.addEventListener('documentLoaded', () => {
      const doc = documentViewer.getDocument();
      const pageNum = 1;
      doc.loadThumbnail(pageNum, (thumbnail) => {
        // thumbnail is a HTMLCanvasElement or HTMLImageElement
        console.log(thumbnail);
      });
    });
  });
```

{% endcode %}

[Document.loadThumbnail](https://sdk.apryse.com/api/web/Core.Document.html#loadThumbnail__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v7.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { docViewer } = instance;
    docViewer.on('documentLoaded', () => {
      const doc = docViewer.getDocument();
      const pageNum = 1;
      doc.loadThumbnailAsync(pageNum, (thumbnail) => {
        // thumbnail is a HTMLCanvasElement or HTMLImageElement
        console.log(thumbnail);
      });
    });
  });
```

{% endcode %}

[Document.loadThumbnailAsync](https://sdk.apryse.com/api/web/Core.Document.html#loadThumbnailAsync__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { docViewer } = instance;
    docViewer.on('documentLoaded', () => {
      const doc = docViewer.getDocument();
      const pageIdx = 0;
      doc.loadThumbnailAsync(pageIdx, (thumbnail) => {
        // thumbnail is a HTMLCanvasElement or HTMLImageElement
        console.log(thumbnail);
      });
    });
  });
```

{% endcode %}

[Document.loadThumbnailAsync](https://sdk.apryse.com/api/web/Core.Document.html#loadThumbnailAsync__anchor)
{% endtab %}
{% endtabs %}

## Create a High resolution page image (png or jpg) with annotations

To create a high resolution page thumnbails and optionally with annotations where the result is a HTMLCanvasElement or HTMLImageElement.

`_loadCanvasAsync_`\_ is deprecated since version 8.3 and removed since version 10.0. Please use *`_loadCanvas_`* instead.\_

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { documentViewer } = instance.Core;
    documentViewer.addEventListener('annotationsLoaded', () => {
      const doc = documentViewer.getDocument();
      const pageNumber = 1;
      const zoom = 2; // render at twice the resolution
      
      doc.loadCanvas({
        pageNumber,
        zoom,
        drawComplete: async (thumbnail) => {
          const corePageRotation = (doc.getPageRotation(pageNumber) / 90) % 4;
          annotationManager.setAnnotationCanvasTransform(thumbnail.getContext('2d'), zoom, corePageRotation);

          // optionally comment out "drawAnnotations" below to exclude annotations
          await instance.Core.documentViewer.getAnnotationManager().drawAnnotations(pageNumber, thumbnail);
          // thumbnail is a HTMLCanvasElement or HTMLImageElement
          console.log(thumbnail);
        }
      });
    });
  });
```

{% endcode %}

[Document.loadCanvas](https://sdk.apryse.com/api/web/Core.Document.html#loadCanvas__anchor) [AnnotationManager.drawAnnotations](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#drawAnnotations__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v7.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { docViewer } = instance;
    docViewer.on('annotationsLoaded', () => {
      const doc = docViewer.getDocument();
      const pageNumber = 1;
      const zoom = 2; // render at twice the resolution
      
      doc.loadCanvasAsync({
        pageNumber,
        zoom,
        drawComplete: async (thumbnail) => {
          const corePageRotation = (doc.getPageRotation(pageNumber) / 90) % 4;
          annotationManager.setAnnotationCanvasTransform(thumbnail.getContext('2d'), zoom, corePageRotation);

          // optionally comment out "drawAnnotations" below to exclude annotations
          await instance.docViewer.getAnnotationManager().drawAnnotations(pageNumber, thumbnail);
          // thumbnail is a HTMLCanvasElement or HTMLImageElement
          console.log(thumbnail);
        }
      });
    });
  });
```

{% endcode %}

[Document.loadCanvasAsync](https://sdk.apryse.com/api/web/Core.Document.html#loadCanvasAsync__anchor) [AnnotationManager.drawAnnotations](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#drawAnnotations__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { docViewer } = instance;
    docViewer.on('annotationsLoaded', () => {
      const doc = docViewer.getDocument();
      const pageIdx = 0;
      const zoom = 2; // render at twice the resolution
      
      doc.loadCanvasAsync({
        pageIndex: pageIdx,
        zoom,
        drawComplete: async (thumbnail) => {
          const pageNumber = 1;
          const corePageRotation = (doc.getPageRotation(pageNumber) / 90) % 4;
          annotationManager.setAnnotationCanvasTransform(thumbnail.getContext('2d'), zoom, corePageRotation);
          
          // optionally comment out "drawAnnotations" below to exclude annotations
          await instance.docViewer.getAnnotationManager().drawAnnotations(pageNumber, thumbnail);
          // thumbnail is a HTMLCanvasElement or HTMLImageElement
          console.log(thumbnail);
        }
      });
    });
  });
```

{% endcode %}

[Document.loadCanvasAsync](https://sdk.apryse.com/api/web/Core.Document.html#loadCanvasAsync__anchor) [AnnotationManager.drawAnnotations](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#drawAnnotations__anchor)
{% 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/web/generate/thumbnail.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.
