---
title: captureScreenshot
slug: viewer-2d/methods/captureScreenshot
docTags: 
createdAt: 2024-02-21T14:33:53.989Z
---

Takes a screenshot of the viewer in PNG format.

## Example

::codepen{url="https://codepen.io/Catenda/embed/yLdPQBY"}

## Usage

```javascript
const options = {
  width: 1024,
  height: 768
};

const imageDataPromise = viewer2d.captureScreenshot(options);
```

## Parameters

### options

Options for the screenshot.

| **Type** | **Required** |
| -------- | ------------ |
| Object   | Yes          |

**Properties**

| **Name** | **Type** | **Required** | **Description**                    |
| -------- | -------- | ------------ | ---------------------------------- |
| `height` | Number   | Yes          | Height of the screenshot in pixels |
| `width`  | Number   | Yes          | Width of the screenshot in pixels  |

## Return Value

Promise that resolves to the base64 encoded string of the PNG image.

| **Type**            |
| ------------------- |
| `Promise => String` |

