Products Technologies Demo Docs Blog Support Company

Form Field Compatibility: Work with AcroForms, Legacy MS Word Forms, and Content Controls

This article shows how to work with form fields in TX Text Control and how they are compatible with other industry standards. It explains how to load and save AcroForms, legacy MS Word forms and content controls.

Form Field Compatibility: Work with AcroForms, Legacy MS Word Forms, and Content Controls

TX Text Control provides a comprehensive set of features for creating and deploying electronic forms, including form fields such as form text fields, check boxes, and drop-down lists. The Document Editor can be used to create these forms, and the Document Viewer can be used to deploy these forms to collect the data.

The proprietary form fields provided by TX Text Control are fully integrated into the document and into the overall workflow of the document. Fields can contain conditional logic (instructions) to validate and automate the contents of form fields and can be inserted directly into a document.

TX Text Control form fields are compatible with other industry standards such as AcroForms, legacy MS Word forms, and content controls. This article shows how to load and save these form fields using TX Text Control.

MS Word Form Fields

MS Word supports two types of form fields. Legacy form fields, as the name implies, are from older versions of MS Word such as MS Word 97, but are still compatible and usable in newer versions. On the other hand, content control form fields are the modern version of the form fields in MS Word.

Both of these types can be imported into the TX Text Control when you load the RTF, DOC, or DOCX (Office Open XML) document types. They will be converted to proprietary TX Text Control form fields.

When loading a document, the ApplicationFieldFormat property can be used to specify how a field is imported. There are three relevant options that can be specified when importing fields:

  • None
    Text fields supported by other applications are not imported as ApplicationFields. Form fields are imported as TX Text Control FormFields.
  • MSWord
    Fields that are supported and defined by Microsoft Word are imported as ApplicationFields. The ApplicationFieldTypeNames property can be used to select specific types of fields.
  • MSWordTXFormFields
    Fields that are supported and defined by Microsoft Word are imported as ApplicationFields, with the exception of form fields. Form fields such as combo boxes, check boxes, and form text fields are imported as TX Text Control FormFields.

These two types can be loaded as proprietary form fields or as ApplicationFields. The list below shows the different settings and the result:

Field Document Format Imported as ( LoadSettings)
None MSWord MSWordTXFormFields
Content Control MSWord, WordprocessingML, RichTextFormat FormFields ApplicationField FormFields
Legacy Form Fields MSWord, WordprocessingML, RichTextFormat FormFields ApplicationField FormFields

Loading Form Fields

The following code shows how to load the document with legacy and content control form fields that are automatically converted to TX Text Control fields:

TXTextControl.LoadSettings loadSettings = new TXTextControl.LoadSettings()
{
  ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWordTXFormFields
};

using (TXTextControl.ServerTextControl serverTextControl = 
  new TXTextControl.ServerTextControl())
{
  serverTextControl.Create();
  serverTextControl.Load("contentcontrols.docx", 
    TXTextControl.StreamType.WordprocessingML, loadSettings);

  foreach (FormField ff in serverTextControl.FormFields)
  {
    Console.WriteLine(ff.Text);
  }
}

When the document is loaded, the form fields are converted to TX Text Control form fields. The FormField collection can be used to access and manipulate these fields.

Learn More

This article shows how to work with content controls in MS Word documents using TX Text Control in C#. Content controls are used to create structured documents and forms. This article shows how to import and process content controls in MS Word documents using TX Text Control.

Working with Content Controls in MS Word Documents using TX Text Control in C#

Saving Form Fields

When saving the document, the form fields are saved as proprietary TX Text Control form fields when saving in the internal TX Text Control format. When exporting to MS Word formats, different form field types are exported:

Format Form Field Type
Office Open Xml (DOCX) Content Control
MS Word (DOC) Legacy Form Field
Rich Text Format (RTF) Legacy Form Field

PDF AcroForms

AcroForms are a feature of the PDF file format that allows for the creation of forms within PDF documents. These forms can contain form fields such as text fields, check boxes, radio buttons, and drop-down lists.

Learn More

TX Text Control can be used for the creation and processing of PDF form fields. This article shows how to create, select, flatten, and extract form fields in PDF documents.

Create, Pre-Select, Flatten and Extract PDF Form Fields using C#

Exporting AcroForms

When exporting documents with form fields to PDF, these fields are exported in the form of Acroforms automatically. All supported form field types are exported to the corresponding AcroForms type, including field names and content values.

Have a look at the following document in TX Text control, which is shown in the screenshot below:

Forms with TX Text Control

When exporting this document to PDF, the form fields are exported as AcroForms:

Forms with TX Text Control

Importing AcroForms

Interactive forms in Adobe PDF format - also known as AcroForm - are a de facto standard for processing PDF forms. The forms can be created and exported using the TX Text Control, allowing the end user to fill in the form fields in Acrobat Reader or other applications.

In order to collect results from completed documents, the TX Text Control allows you to extract data from form fields.

The following code shows how to get all the AcroForm fields from the above sample PDF document using the GetAcroFormFields method, which accepts filenames and byte arrays.

FormField[] acroForms = Forms.GetAcroFormFields("lease_agreement.pdf");

foreach (FormField field in acroForms) {
    switch (field) {
        case FormTextField textField:
            Console.WriteLine("Field \"{0}\" extracted: {1}",
                textField.FieldName,
                textField.Value);
            break;

        case FormCheckBox checkBoxField:
            Console.WriteLine("Field \"{0}\" extracted: {1}",
                checkBoxField.FieldName,
                checkBoxField.IsChecked.ToString());
            break;

        case FormComboBox comboBoxField:
            Console.WriteLine("Field \"{0}\" extracted. Selected value: {1}",
                comboBoxField.FieldName,
                comboBoxField.Value);

            foreach (var item in comboBoxField.Options) {
                Console.WriteLine(" -> Option: {0}", item);
            }

            break;
    }
}

The output lists all completed form fields including the name and possible drop-down options:

Field "insurance_date" extracted: 1/1/2020
Field "insurance_name" extracted: Health Providers
Field "insurance_check" extracted: True
Field "notes" extracted: Thanks for your business.
Field "insurance_state" extracted. Selected value: North Carolina
 -> Option: Georgia
 -> Option: California
 -> Option: North Carolina

Conclusion

TX Text Control form fields are fully integrated into the document and into the overall workflow of the document. Fields can contain conditional logic (instructions) to validate and automate the contents of form fields and can be inserted directly into a document.

TX Text Control form fields are compatible with other industry standards such as AcroForms, legacy MS Word forms, and content controls. This article showed how to load and save these form fields using TX Text Control.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

AngularASP.NETReact

Comments JavaScript API: Useful Tips and Tricks

The Comments JavaScript API is a powerful interface to customize the behavior of comments in the Document Editor. This article provides useful tips and tricks to get the most out of it.


AngularASP.NETReact

Integrating Document Lifecycle Management with ASP.NET Core and C#

In this article, we will explore how to integrate document lifecycle management with ASP.NET Core and C#. We will illustrate why document lifecycle management is important and how it can be…


AngularASP.NETJavaScript

Building an ASP.NET Core Backend Application to Host the Document Editor and…

This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality…


ASP.NETAcroFormsForm Fields

Healthcare Use Case: Digital Forms Workflow with Electronic Signatures

Forms play an important role in healthcare processes and offer a huge potential for automation and digital forms processing. This article and sample show how to use TX Text Control to streamline…


AngularASP.NETForm Fields

Converting DOCX Form Fields to Smart HTML Forms

TX Text Control provides a sophisticated way to create and deploy forms using the online editor and document viewer. This article shows how to convert forms to pure HTML forms to collect data in…