PDFPageElement: 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 PDFPageElement interface fires when a <pdf-page> knows its page: its file has loaded and the page box has its size.

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-page-load instead.

Event type

A CustomEvent. Inherits from Event.

EventCustomEvent

Description

The page fires load before it draws, every time it starts drawing for a change that affects it: a new file, another page number, scale, rotation, engine or layer. A lazy page fires load once it is sized and render later, when it comes near the viewport and is drawn.

Examples

Reading the page size on load

js
const page = document.querySelector("pdf-page");
page.addEventListener("load", () => {
  const style = getComputedStyle(page);
  console.log(style.getPropertyValue("--width"), style.getPropertyValue("--height"));
});

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