> ## Documentation Index
> Fetch the complete documentation index at: https://webviewer-docs.mupdf.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture API

The [`capture`](#capture) object is an instance accessible from the main [MuPDFWebViewer](/api-reference/introduction#initmupdfwebviewer) instance as follows:

```javascript theme={null}
const capture = webViewer.capture;
```

<Note>
  This assumes you have returned your instance name as `webViewer` from the [initMuPDFWebViewer()](/api-reference/introduction#initmupdfwebviewer) promise!
</Note>

## capture

The `capture` object has the following methods:

### selectAndExport

```typescript theme={null}
selectAndExport(): Promise<{ imageBytes: Uint8Array }>;
```

Once this method is called it allows the user to select a region which is then exported as an image and returned as a promise with the image data.

#### Returns

<ResponseField name="result" type="Promise<{ imageBytes: Uint8Array }>" required>
  A Promise that resolves to the captured image bytes.
</ResponseField>

<Note>
  Captured images do not include viewer-only overlays such as those created with [viewer.highlight()](/api-reference/viewer/index#highlight). To include highlighted regions in output, create real PDF annotations with [annotation.add()](/api-reference/annotation/index#add) first.
</Note>

**Example**

```javascript theme={null}
webViewer.capture.selectAndExport().then(captureSuccess, captureFailure)

function captureSuccess(data) {
    console.log(`Capture data is: ${data.imageBytes}`);
}

function captureFailure(error) {
    console.error(`Capture error: ${error}`);
}
```
