Products Technologies Demo Docs Blog Support Company

Form Field Handling in PDF Documents

Since TX Text Control supports form fields, it is possible to either export form fields in the PDF document or to flatten the form fields to export text only without the field functionality. This article shows how to flatten form fields before exporting to PDF.

Form Field Handling in PDF Documents

TX Text Control supports the integration of form fields into documents including form text fields, checkboxes, drop-down boxes and date pickers. Those documents can be deployed using TX Text Control in web or desktop applications using the document editor or the document viewer.

Form fields and TX Text Control

Export Form Fields

Additionally, it is possible to export Adobe PDF documents with included form fields. After loading this document in Adobe Acrobat Reader, the document is recognized automatically as a form and users can complete the fields.

Form fields and TX Text Control

Learn More

Interactive forms in an Adobe PDF document can be used to gather information from end-users. This article shows how to create those forms using TX Text Control in .NET applications using C#.

Creating Adobe PDF Forms in C#

Flatten Form Fields

But what if the document should be exported to PDF without the form field functionality, but plain text. A typical workflow would be the creation of a final document where form fields have been completed already and a resulting document with the actual form field values should be created.

The Remove method of the FormFieldCollection can be used to replace the field with the actual content. The following function iterates through all form fields in order to remove the field functionality:

private void FlattenFormFields(TextControl textControl) {
  int fieldCount = textControl1.FormFields.Count;

  for (int i = 0; i < fieldCount; i++) {
    TextFieldCollectionBase.TextFieldEnumerator fieldEnum =
      textControl1.FormFields.GetEnumerator();
    fieldEnum.MoveNext();

    FormField curField = (FormField)fieldEnum.Current;
    textControl1.FormFields.Remove(curField, true);
  }
}

The above method can be easily called with a given TextControl or a ServerTextControl instance.

FlattenFormFields(textControl1);

The following screenshot shows the flattened PDF document without the form fields, but the textual content:

Form fields and TX Text Control

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • TXTextControl.FormFieldCollection Class
  • TXTextControl.FormFieldCollection.Remove Method
  • TXTextControl.ServerTextControl.FormFields Property

Related Posts

ASP.NETWindows FormsWPF

Extract Text and Data from PDF Documents in C#

TX Text Control can be used to create and edit Adobe PDF documents programmatically. But it is also possible to import PDF documents to read, extract and manipulate them. This article shows…


ASP.NETWindows FormsWPF

Creating PDF Files using TX Text Control .NET in C#

TX Text Control allows developers to create PDF files programmatically using C#. This article shows various ways to create Adobe PDF documents.


ASP.NETJavaScriptWindows Forms

Generating Interactive PDF Forms by Injecting JavaScript

Using TX Text Control, it is possible to export documents with form fields to fillable PDFs. This article shows how to inject JavaScript to add interaction to form fields.


ASP.NETWindows FormsWPF

Creating ZUGFeRD Compliant PDF Invoices in C#

ZUGFeRD / Factur-X documents can be created and extracted using TX Text Control X19. This article shows how to create a valid ZUGFeRD compliant invoice PDF document from scratch.


ASP.NETWindows FormsWPF

X19 Sneak Peek: Processing AcroForm Fields in Adobe PDF Documents

TX Text Control X19 will introduce a new namespace that contains classes to process PDF documents. A new feature allows the extraction of AcroForm fields from existing Adobe PDF documents.