Since TX Text Control X16, the Adobe PDF import filter is able to import form fields. Interactive forms in the Adobe PDF format are also known as AcroForm - the de-facto standard for PDF forms processing. Internally, the forms structure of a PDF document can be imported using the Adobe PDF import functionality of TX Text Control.

We just published a GitHub project that shows how to process the output of the PDF import process using an extension in the DocumentServer namespace. We implemented all base classes and inherited classes of supported form field elements:

  • TextField
  • CheckBox
  • RadioButton
  • Listbox
  • ComboBox
  • Button

AcroForms in TX Text Control

After adding a reference to the TXDocumentServer.Forms project, a PDF form can be imported using the following code:

AcroForm[] listAcroForms = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf");
view raw test.cs hosted with ❤ by GitHub

The static ImportForms method returns a list of AcroForm objects:

AcroForms in TX Text Control

The list of AcroForm objects contains all types of contained form fields. In order to access the properties, they can be casted to their special type. The following code loops through all elements in order to read the options of contained combo boxes:

AcroForm[] listAcroForms = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf");
foreach (AcroForm formElement in listAcroForms)
{
if(formElement.GetType() == typeof(AcroFormComboBox))
{
string[] saOptions = ((AcroFormComboBox)formElement).Options;
}
}
view raw data.cs hosted with ❤ by GitHub

This new feature allows you to import forms that have been sent to users for completion in order to analyze and process the forms automatically.

Sample Project

The following Windows Forms sample project uses a pre-compiled version of the extension and comes with a sample PDF document.

Download Project

Instructions

  • Download the sample project, open it in Visual Studio 2017 and start the application.

  • Click the button Import Forms and select a PDF file you would like to import. A sample PDF named fw9.pdf is shipped with the project.

The sample loops through all elements in order to write the element type, name and value into a text box.

You can download the full extension sources from the GitHub project below.