PDFFileElement: load 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 load event of the PDFFileElement interface fires when a <pdf-file> has loaded its PDF: after every successful load, including reloads.

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 onload event handler property.

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

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

Event type

A CustomEvent. Inherits from Event.

EventCustomEvent

Examples

Reading the page count

js
const file = document.querySelector("pdf-file");
file.addEventListener("load", () => console.log(file.js.numPages));

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

Legend

Full support

See also