Import Data into PDF Forms Using XFDF
In Standalone mode it’s possible to set form field values in a document by importing them as XFDF:
const XFDF = `<?xml version="1.0" encoding="UTF-8"?> <xfdf xml:space="preserve" xmlns="http://ns.adobe.com/xfdf/"> <annots></annots> <fields> <field name="Form field 1"> <value>Text for form field 1</value> </field> </fields> <ids modified="8AFBEA0B224C4F2BAE69171EF4FCE3C0" original="CC968B2893024520A316261F10B8978C"/> </xfdf> ` PSPDFKit.load({ XFDF });
The snippet above will prefill the form field named “Form Field 1” with the text “Text for form field 1”.
You can also import form field values as XFDF using document operations, available with the Document Editor license component:
const xfdf = `<?xml version="1.0" encoding="UTF-8"?> <xfdf xml:space="preserve" xmlns="http://ns.adobe.com/xfdf/"> <annots></annots> <fields> <field name="Form field 1"> <value>Text for form field 1</value> </field> </fields> <ids modified="8AFBEA0B224C4F2BAE69171EF4FCE3C0" original="CC968B2893024520A316261F10B8978C"/> </xfdf> ` instance.applyOperations([ { type: "applyXfdf", xfdf } ]);