PDFPageElement: rotation 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 rotation property of the PDFPageElement interface sets or returns the rotation of a <pdf-page>, in degrees clockwise. It reflects the rotation HTML attribute.

Value

An integer: 0, 90, 180 or 270. The default is the rotation the PDF stores for the page (its /Rotate).

The rotation is absolute: it replaces the one in the file. You can set any multiple of 90, including negative ones; the property normalizes it, so -90 reads as 270. Setting the page's own rotation removes the attribute.

A quarter turn swaps the page box's width and height (and the --width and --height custom properties). With controls, Q and E turn the page by a quarter, S by half, and two fingers twisted on a touch screen by a quarter per 90°.

Examples

Rotating a page

Each click turns the page a quarter clockwise.

HTML

html
<pdf-file id=f src=//pdf.ist/web.pdf></pdf-file>
<button type=button>Rotate</button>
<pdf-page of=f id=page scale=0.3></pdf-page>

CSS

css
button { display: block; margin-bottom: 1rem; }

JavaScript

js
const page = document.querySelector("#page");
document.querySelector("button").addEventListener("click", () => {
  page.rotation += 90; // 0 → 90 → 180 → 270 → 0
});

Result

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

Legend

Full support

See also