PDFFileElement: password 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 password property of the PDFFileElement interface sets or returns the password a <pdf-file> opens an encrypted PDF with. It reflects the password HTML attribute.

Value

A string. The default is the empty string. Setting it opens the file again.

A file that needs a password fires error with PDF.js's PasswordException until it gets the right one; it is not retried through the proxy.

Examples

Asking for a password

js
const file = document.querySelector("pdf-file");
file.addEventListener("error", (event) => {
  if (event.detail?.name === "PasswordException") file.password = prompt("Password?");
});

Specifications

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

Specification
ISO 32000-2:2020 (PDF 2.0)

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

Legend

Full support

See also