Reading Form Field Values

The values of Acro Form fields are read from an existing PDF document using the Form property of the MergeDocument class. In addition to being to read out the actual text values of the Form Fields, formatting of that Form Field (including font, font size, font color, background color, border color and border style) can also be retrieved.

This example shows how to read the value of several Acro Form fields from an existing PDF document:

// Create a PdfDocument object
MergeDocument document = new MergeDocument(pdfFilePath);
// Set the Acro Form field values to local variables
string textBox1Value = document.Form.Fields["TextBox1"].Value;
string checkBox1Value = document.Form.Fields["CheckBox1"].Value;
string comboBox1Value = document.Form.Fields["ComboBox1"].Value;
string radioButton1Value = document.Form.Fields["RadioButton1"].Value;
string listBox1Value = document.Form.Fields["ListBox1"].Value;        
Dim MyMergeDocument As MergeDocument = New MergeDocument(pdfFilePath)
' Set the Acro Form field values to local variables
Dim TextBox1Value As String = MyMergeDocument.Form.Fields("TextBox1").Value
Dim CheckBox1Value As String = MyMergeDocument.Form.Fields("CheckBox1").Value
Dim ComboBox1Value As String = MyMergeDocument.Form.Fields("ComboBox1").Value
Dim RadioButton1Value As String = MyMergeDocument.Form.Fields("RadioButton1").Value
Dim ListBox1Value As String = MyMergeDocument.Form.Fields("ListBox1").Value

In this topic