PDFPageElement: render 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 render event of the PDFPageElement interface fires when a <pdf-page> has drawn: its image and the layers that changed are in place.

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

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

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

Event type

A CustomEvent. Inherits from Event.

EventCustomEvent

Event properties

This interface also inherits properties from its parent, Event.

detail

An object:

reason

What started the render: an object such as { a: "scale", o: "1", n: "2" } (an attribute, its old and its new value), { file: "src" } or {}, or an array of them when several changes drew at once.

touched

Which parts were drawn again, as booleans: all (the page itself changed), image, text and anno.

Examples

Exporting after each render

js
const page = document.querySelector("pdf-page");
page.addEventListener("render", async (event) => {
  if (!event.detail.touched.image) return;
  const png = await page.image.export();
  console.log(`${png.size} bytes`);
});

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

Legend

Full support

See also