Working with XFA Forms

XFA Form Filling

DynamicPDF Merger supports filling static XFA forms provided those XFA forms contain a field entry. Merging is done through the Form property of the MergeDocument class. XFA Form field values are set as merged into a new PDF document. The specified value must match the form field's export value. Unicode values are fully supported.

Form

The MergeDocument class has a Fields property. This property is a FormFieldsList. A FormFieldList class's values are referenced by the field's name or index number.

A Form also provides a FormFieldsAdded event for handling events when adding form fields.

Example

The following example shows how to set the values of an XFA Acro Form.

MergeDocument document = new MergeDocument(pdfFilePath);
// Set the field values
document.Form.Fields["topmostSubform[0].Page1[0].TextBox1[0]"].Value = "My Text";  
document.Form.Fields["topmostSubform[0].Page1[0].ComboBox1[0]"].Value = "Item4";   
document.Form.Fields["topmostSubform[0].Page1[0].CheckBox1[0]"].Value = "Yes";
document.Form.Fields["topmostSubform[0].Page1[0].RadioButton1[0]"].Value = "Item2"; 
// Save the PDF         
document.Draw(pdfFilePath);
Dim MyDocument As MergeDocument = New MergeDocument(pdfFilePath)
' Set the field values
MyDocument.Form.Fields("topmostSubform[0].Page1[0].TextBox1[0]").Value = "My Text"  
MyDocument.Form.Fields("topmostSubform[0].Page1[0].ComboBox1[0]").Value = "Item4"   
MyDocument.Form.Fields("topmostSubform[0].Page1[0].CheckBox1[0]").Value = "Yes"
MyDocument.Form.Fields("topmostSubform[0].Page1[0].RadioButton1[0]").Value = "Item2"
' Save the PDF         
MyDocument.Draw(pdfFilePath)

In this topic