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 TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
LoadSettings Class
ApplicationFieldFormat Property
Specifies the format of text fields which are imported.
property can be used to specify how a field is imported. There are three relevant options that can be specified when importing fields:

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 TX Text Control .NET for Windows Forms
TXTextControl Namespace
LoadSettings Class
ApplicationFieldFormat Property
Specifies the format of text fields which are imported.
)
None MSWord MSWordTXFormFields
Content Control MSWord, WordprocessingML, RichTextFormat FormFields TX Text Control .NET for Windows Forms
TXTextControl Namespace
FormField Class
The FormField class is the base class of all form fields.
ApplicationField TX Text Control .NET for Windows Forms
TXTextControl Namespace
ApplicationField Class
The ApplicationField class supports text field formats of applications such as Microsoft Word.
FormFields TX Text Control .NET for Windows Forms
TXTextControl Namespace
FormField Class
The FormField class is the base class of all form fields.
Legacy Form Fields MSWord, WordprocessingML, RichTextFormat FormFields TX Text Control .NET for Windows Forms
TXTextControl Namespace
FormField Class
The FormField class is the base class of all form fields.
ApplicationField TX Text Control .NET for Windows Forms
TXTextControl Namespace
ApplicationField Class
The ApplicationField class supports text field formats of applications such as Microsoft Word.
FormFields TX Text Control .NET for Windows Forms
TXTextControl Namespace
FormField Class
The FormField class is the base class of all form fields.

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);
}
}
view raw test.cs hosted with ❤ by GitHub

When the document is loaded, the form fields are converted to TX Text Control form fields. The FormField TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
FormField Class
The FormField class is the base class of all form fields.
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 TX Text Control .NET Server for ASP.NET
DocumentServer.PDF Namespace
Forms Class
GetAcroFormFields Method
Imports AcroFormFields from an Adobe PDF document.
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;
}
}
view raw test.cs hosted with ❤ by GitHub

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.