PDFFileElement: formData 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 formData property of the PDFFileElement interface sets or returns the values of the form fields of a <pdf-file>.

Value

An object whose keys are annotation IDs (such as "12R") and whose values are objects with a value property, as PDF.js stores them. Setting it applies the values to every page.

When PDFium holds the form (js in the file's -), the keys are field names, and the object has the fields that were changed. Setting it takes field names too, with a { value } object or the value itself: a string for a text field, an array of options for a list, true, false or an export value for a check box, and the export value of a radio button.

To read or write form data as a file, use XFDF; to save the filled PDF, use PDFFileElement.save().

Examples

Reading the filled values

js
const file = document.querySelector("pdf-file");
for (const [id, { value }] of Object.entries(file.formData)) console.log(id, value);

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)
# 12.7 Forms

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

Legend

Full support

See also