PDFFileElement: src 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 src property of the PDFFileElement interface sets or returns the URL of the PDF a <pdf-file> loads. It reflects the src HTML attribute.

Value

A string: an absolute or relative URL. data: and blob: URLs work too.

Setting it loads the new file, and every page of the file follows. If the direct fetch of an http: or https: URL fails (CORS, network or an HTTP error), the file fetches it once more through the built-in proxy; see proxy. The file fires load when it loads, and error only when the retry fails too.

name follows the last part of the URL.

Examples

Loading a file by URL

HTML

html
<pdf-file id=f src=//new.webpdf.pro/forms.pdf></pdf-file>
<pdf-page of=f scale=0.5></pdf-page>

Result

Switching the file from script

js
const file = document.querySelector("pdf-file");
file.src = "//pdf.ist/web.pdf"; // every page of the file shows the new PDF

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

Legend

Full support

See also