PDFFileElement: data 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 data property of the PDFFileElement interface sets or returns the bytes of the PDF a <pdf-file> has loaded.

Value

Reading it gives a Uint8Array of the file as it was when it loaded, or a Promise for one when the file came from src. Form edits are not in it; use PDFFileElement.saveData() for those.

Setting a Uint8Array or an ArrayBuffer loads those bytes: the file drops its src and its name.

Examples

Loading bytes

js
const file = document.querySelector("pdf-file");
const response = await fetch("report.pdf");
file.data = new Uint8Array(await response.arrayBuffer());

Reading the bytes of a file loaded by URL

js
const file = document.querySelector("pdf-file");
const bytes = await file.data; // Uint8Array
console.log(bytes.length);

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

Legend

Full support

See also