PDFPageElement: error event

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 error event of the PDFPageElement interface fires when a <pdf-page> fails: it cannot find its file, or its engine fails to draw it.

This event is not cancelable and bubbles. It is also composed, so it crosses shadow root boundaries unless composed is false.

Syntax

Use the event name in methods like addEventListener(). WebPDF elements have no onerror event handler property.

js
addEventListener("error", (event) => { })

With event:prefix=type on the <script>, the file or the page, the event is named pdf-page-error instead.

Event type

A CustomEvent. Inherits from Event.

EventCustomEvent

Event properties

This interface also inherits properties from its parent, Event.

detail

An Error: for example a ReferenceError when the page cannot find its file, or the error PDF.js or PDFium raised while drawing.

Description

A page that cannot find its file also sets an error attribute ("Error: cannot find file"), which it removes on its next render. The error event of the file covers loading the PDF.

Examples

Reporting errors

js
document.addEventListener("error", (event) => {
  if (event.target.localName === "pdf-page") console.warn(event.detail);
}, true);

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
error event
1251251531111812515383182712518

Legend

Full support

See also