# Create a PDF Form

> Build a fillable PDF form in Windows Forms: add TextFormField, SelectionFormField and CheckFormField to a TextControl, name them and save the form as PDF.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Getting Started > PDF Processing > Create a PDF Form
- **1878 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/form/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/form/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/form/llms-full.txt

---

Form fields that you insert in a TextControl document become fillable fields when the document is saved as PDF: a text box, a drop-down list or a check box that users fill out in their PDF reader. Starting from the editor of your first application, you insert three form fields in code, give them names, and save and open the PDF form.

### Prerequisites

- The application from [Create Your First Windows Forms Application](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/first-application/llms-full.txt), with a `TextControl` named `textControl1` on `Form1`.
- The Enterprise edition, which includes form fields. See [Editions and Feature Availability](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/editions/llms-full.txt).

Add two buttons to the form, `insertFormButton` and `saveFormButton`, and double-click each one to create its `Click` handler. *Form1.cs* needs these `using` directives:

```csharp
using System.Diagnostics;
using TXTextControl;
```

### How Form Fields Become a PDF Form

TX Text Control has four kinds of form fields: [TextFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textformfield/constructor/llms-full.txt) for text, [CheckFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/checkformfield/constructor/llms-full.txt) for a check box, [SelectionFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selectionformfield/constructor/llms-full.txt) for a drop-down list or a combo box, and [DateFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/llms-full.txt) for a date. You add them to the [FormFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/formfields-property/llms-full.txt) collection of the `TextControl`, which inserts them at the input position.

When the document is saved as PDF, each form field is converted into a PDF form field. No setting is needed for this, and the name you give a field becomes its name in the PDF form.

### Insert the Form Fields

The following code writes three labels and inserts a form field after each of them:

```csharp
private void insertFormButton_Click(object sender, EventArgs e)
{
    textControl1.Selection.Text = "Name: ";
    AddFormField(new TextFormField(3000)   // width in twips while empty
    {
        Name = "name",
        DescriptiveText = "Your full name"
    });

    textControl1.Selection.Text = "\nCountry: ";
    AddFormField(new SelectionFormField(new string[] { "United States", "Germany", "Italy" }, 0)
    {
        Name = "country",
        DescriptiveText = "Your country"
    });

    textControl1.Selection.Text = "\nSend me the newsletter: ";
    AddFormField(new CheckFormField(false)
    {
        Name = "newsletter",
        DescriptiveText = "Subscribe to the newsletter"
    });
}

// Insert a form field and move the input position behind it
private void AddFormField(FormField formField)
{
    textControl1.FormFields.Add(formField);
    textControl1.InputPosition = new InputPosition(
        formField.Start + formField.Length - 1,
        TextFieldPosition.OutsideTextField);
}
```

The code works as follows:

- [Selection.Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/text-property/llms-full.txt) inserts the labels at the input position.
- The constructors create the fields: `TextFormField` with its width in twips while it is empty, `SelectionFormField` with its items and the index of the preselected one, and `CheckFormField` unchecked.
- [Name](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfield/name-property/llms-full.txt) identifies each field in the PDF form, and [DescriptiveText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/formfield/descriptivetext-property/llms-full.txt) describes it, for example as a tooltip in the PDF reader and for screen readers.
- [FormFieldCollection.Add](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/formfieldcollection/add-method/llms-full.txt) inserts the field at the input position.
- After a form field is inserted, the input position is still next to the field. Setting [InputPosition](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/inputposition-property/llms-full.txt) with `TextFieldPosition.OutsideTextField` moves it behind the field, so that the next label is not typed into it.

### Save and Open the PDF Form

```csharp
private void saveFormButton_Click(object sender, EventArgs e)
{
    string path = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
        "form.pdf");

    // Form fields are saved as fillable PDF form fields
    textControl1.Save(path, StreamType.AdobePDF);

    Process.Start(new ProcessStartInfo(path) { UseShellExecute = true });
}
```

Run the application, click **insertFormButton** and then **saveFormButton**. The PDF reader opens *form.pdf* with a text box after "Name:", a drop-down list with three countries after "Country:" and a check box after "Send me the newsletter:". Fill them out and save the PDF in the reader:

![A PDF form in Adobe Acrobat with a filled text field and an open drop-down list offering United States, Germany and Italy.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/pdf-form-drop-down.8ca05713.webp)

### Insert Form Fields With the Ribbon

Users can insert the same form fields without code, with the **Form Fields** tab of the ribbon, the [RibbonFormFieldsTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformfieldstab/llms-full.txt). [Design a Form With the Ribbon](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#design-a-form-with-the-ribbon) shows the tab and how to add it to your form.

### Fill Out the Form in the Editor

The same document can also be filled out in `textControl1` itself: three settings of the editor protect the text and leave only the form fields editable. [Let Users Fill Out the Form](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#let-users-fill-out-the-form) shows them.

### Next Steps

- [Digitally Sign a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/sign/llms-full.txt): sign the PDF with a certificate.
- [PDF Forms](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/forms/llms-full.txt): create, read and flatten PDF forms in detail.
- [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt): form fields in the editor.
- The blog article [Create Fillable PDF Forms in .NET C#](https://www.textcontrol.com/blog/2024/11/12/create-fillable-pdf-forms-in-net-c-sharp/): a complete form built in code.

---

## Nearby

- **Previous:** [Create a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/create/llms-full.txt)
- **Next:** [Digitally Sign a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/sign/llms-full.txt)
