PDFPageImageLayer: export() method

Works in all major browsers
Since July 2026

WebPDF works in Chrome and Edge 125, Firefox 153 and Safari 18, on desktop and mobile, and in every later version: the oldest versions its PDF.js build supports, which already have every platform feature WebPDF needs. Since July 2026, that is every major browser.

The export() method of the PDFPageImageLayer interface returns the image a <pdf-page> draws, as a Blob, a data: URL or a ClipboardItem, in PNG, WebP, JPEG, AVIF or SVG.

Syntax

js
export()
export(type)
export(options)
export(type, options)

Parameters

type Optional

What to return: Blob (the default), URL (a data: URL) or ClipboardItem, ready for navigator.clipboard.write(). A ClipboardItem holds only types the clipboard accepts: browsers take PNG images (Chromium also SVG), so other formats are copied as PNG, and an svg page as SVG and PNG where SVG is accepted.

options Optional

An object with these properties:

type Optional

As the type parameter.

format Optional

The image format: "png", "webp", "jpeg" (or "jpg"), "avif" or "svg", or a MIME type such as "image/png". The default is "svg" for an svg page and "png" otherwise.

quality Optional

A number from 0 to 1 for the lossy formats. The default is 1.

Return value

A Promise that resolves to a Blob, a URL or a ClipboardItem, as type asks.

Exceptions

TypeError

Thrown if type is not Blob, URL or ClipboardItem.

PDFExportError

Rejects with this error, exported by the WebPDF module, for an unknown format, or for "svg" on a page drawn on a canvas.

Usage notes

Examples

Exporting in different types and formats

js
const page = document.querySelector("pdf-page");
await page.image.export();                                 // Blob (image/png)
await page.image.export(URL);                              // URL (data:image/png;base64,…)
await page.image.export({ format: "webp", quality: 0.8 }); // Blob (image/webp)
await page.image.export(Blob, { format: "jpeg" });         // Blob (image/jpeg)

Copying a page to the clipboard

js
const page = document.querySelector("pdf-page");
await navigator.clipboard.write([await page.image.export(ClipboardItem)]);

Specifications

Not part of any specification. <pdf-file> and <pdf-page> are autonomous custom elements defined by WebPDF.pro.

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
export()
1251251531111812515383182712518

Legend

Full support

See also