PDFPageElement: toggleFullscreen() method

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 toggleFullscreen() method of the PDFPageElement interface shows a <pdf-page> fullscreen, or brings it back into the page.

In fullscreen, the page, its layers and the watermark fit the screen together, centered on --pdf-page-fullscreen-background-color. Focus stays where it was, so a focused form field stays focused.

Syntax

js
toggleFullscreen()
toggleFullscreen(force)

Parameters

force Optional

A boolean value: true enters fullscreen, false leaves it. Without it, the page toggles.

Return value

A Promise that resolves to true when the page entered or left fullscreen as asked, and to false when the browser refused or fullscreen is unavailable.

Exceptions

None: a refusal resolves to false instead of rejecting.

Usage notes

Examples

A fullscreen button

HTML

html
<pdf-file id=f src=//pdf.ist/web.pdf></pdf-file>
<button type=button>Fullscreen</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", async () => {
  const ok = await page.toggleFullscreen(true);
  if (!ok) console.log("Fullscreen is not available here.");
});

Result

Specifications

Not part of any specification. <pdf-file> and <pdf-page> are autonomous custom elements defined by WebPDF.pro. It implements:

Specification
Fullscreen API
# ref-for-dom-element-requestfullscreen

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
toggleFullscreen()
12512515311118125153831827125No
  • toggleFullscreen() · Safari on iOS: Only available on iPad, not on iPhone: there, toggleFullscreen() resolves to false.
  • toggleFullscreen() · WebView on iOS: Not available: toggleFullscreen() resolves to false.

Legend

Full support
Partial support
No support
See implementation notes.

See also