PDFPageImageLayer: metrics 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 metrics read-only property of the PDFPageImageLayer interface returns the size of the image a <pdf-page> has drawn.

Value

An object, or undefined before the page has drawn:

width

The image's width in pixels: the canvas's pixel width, or the SVG's width.

height

The image's height in pixels.

aspectRatio

A string such as "612 / 792", ready for the CSS aspect-ratio property.

orientation

An object with three booleans, of which one is true: portrait, landscape and square.

Examples

Measuring a page

js
const page = document.querySelector("pdf-page");
page.addEventListener("render", () => {
  const { width, height, aspectRatio } = page.image.metrics;
  console.log(width, height, aspectRatio); // 612 792 "612 / 792"
});

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

Legend

Full support

See also