PDFPageElement: file 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 file read-only property of the PDFPageElement interface returns the <pdf-file> element whose pages the <pdf-page> shows: the one of names, otherwise the closest <pdf-file> ancestor.

Value

A PDFFileElement, or null when the page has no file.

Examples

Reading the file name

A page knows its file, so it can tell you the file's name and page count once the file has loaded.

js
const page = document.querySelector("pdf-page");
page.addEventListener("load", () => {
  const { name, js } = page.file;
  console.log(`${name}: ${js.numPages} pages`); // "web.pdf: 4 pages"
});

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

Legend

Full support

See also