PDFElement: placeholder 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 placeholder property of the PDFElement interface returns an object that sets the box a page keeps while its PDF is on the way. Its aspectRatio property reflects the placeholder:aspect-ratio HTML attribute.

Value

An object with one property:

aspectRatio

A string: this element's own value, or "" when it has none (and inherits):

A paper name

A4, letter, A5, B5, legal, tabloid and the other names of paper.rt.ht, in any case: the box has that paper's size.

A ratio

Such as 16/9 or 1.5: the box has that shape and the area of the visitor's paper, so 297/210 is A4 in landscape.

-

No box: the page has no size until its PDF arrives.

The attribute is multi-homed: it works on the WebPDF <script>, on every <pdf-file> and on every <pdf-page>, and the nearest one wins.

Without any, the box is the paper of the visitor's region (US Letter in the Americas' letter countries, A4 elsewhere). A size remembered from an earlier visit and pdf-page { --width; --height } come first. See Lazy pages and placeholders.

Examples

Reserving A4 boxes for every page

html
<script src=//new.webpdf.pro/.js type=module placeholder:aspect-ratio=A4></script>

Slides

js
document.querySelector("pdf-file").placeholder.aspectRatio = "16/9";

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

Legend

Full support

See also