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.

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.
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.
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#.
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 Form
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 Text
FlattenFormFields(textControl1);
The following screenshot shows the flattened PDF document without the form fields, but the textual content:
Also See
This post references the following in the documentation:
- TXText
Control. Form Field Collection Class - TXText
Control. Form Field Collection. Remove Method - TXText
Control. Server Text Control. Form Fields Property
Related Posts
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…
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.
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.
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.