Skip to main content
The capture object is an instance accessible from the main MuPDFWebViewer instance as follows:
const capture = webViewer.capture;
This assumes you have returned your instance name as webViewer from the initMuPDFWebViewer() promise!

capture

The capture object has the following methods:

selectAndExport

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

result
Promise<{ imageBytes: Uint8Array }>
required
A Promise that resolves to the captured image bytes.
Captured images do not include viewer-only overlays such as those created with viewer.highlight(). To include highlighted regions in output, create real PDF annotations with annotation.add() first.
Example
webViewer.capture.selectAndExport().then(captureSuccess, captureFailure)

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

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