PDFPageElement: canvas property

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 canvas property of the PDFPageElement interface sets or returns which engine draws a <pdf-page> on its <canvas>: PDF.js or PDFium. It reflects the canvas HTML attribute.

Value

A string:

".js"

PDF.js, the engine of Firefox. This is the default unless the file has its own ium, or the <script> has ium=+.

"ium"

PDFium, the engine of Chrome, compiled to WebAssembly and run in a worker. This is the default for a file with its own ium, and for every file under <script ium=+>.

Any other value reads as "ium". The setter writes the attribute only when the value differs from the default.

Note: PDFium draws only for files with ium on, their own or the script's (a bare ium on the script makes PDFium available without making it the default): without it, canvas=ium still draws with PDF.js. PDFium (about 2.4 MB) loads with the first page that needs it.

A PDFium page still reads the file through PDF.js: its size, text, links and form fields come from PDF.js. With js in -, PDFium reads the page alone.

svg wins over canvas. With controls, J switches to PDF.js and I to PDFium.

Examples

One page, two engines

The same page drawn by PDF.js and by PDFium, side by side.

HTML

html
<pdf-file id=f src=//pdf.ist/web.pdf ium></pdf-file>
<pdf-page of=f canvas=.js scale=0.3></pdf-page>
<pdf-page of=f canvas=ium scale=0.3></pdf-page>

Result

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
canvas
1251251531111812515383182712518

Legend

Full support

See also