Fillable Forms are frequently used in Microsoft Word Documents like DOC, DOCX, and other file formats. In this article, we will create a fillable form in Word document programmatically using C# with Aspose.Words for .NET API. Moreover, we will also cover removing or deleting fillable form fields.
You can configure Aspose.Words for .NET API in your .NET application and subsequently use it with C# or VB.NET. You can either download the DLL from the New Releases section or configure it using following NuGet command.
PM> Install-Package Aspose.Words -Version 20.8.0
Moreover, you can also install the API using NuGet Manager for Solution tool in Visual Studio, as shown in the screenshot below:
So the API has been configured at this step. Let us proceed to learn the following use cases:
- Create fillable form fields with Check box, Text box in Word using C#
- Delete a fillable form field from a Word Document using C#
Create Fillable Form Fields with Check box, Text box in Word using C#
You can create or insert check boxes in word document easily with few basic steps. In addition to the check box, we will also explore how to add text box and combo box. Following are the steps for inserting or adding check box, text box, and combo box in a DOCX file.
- Initialize a new Word document
- Insert Text form field with InsertTextInput method
- Insert check box field using InsertCheckBox method
- Insert combo box field with InsertComboBox method
- Save output word file
The code snippet below shows how to insert fillable field like check box, text box, and combo box in Word files (DOC/DOCX) in C#:
Furthermore, Aspose.Words for .NET API is a feature-rich API that lets you set many properties of the form fields. For example, FormField class can be used to set size, default value, entry and exit macros, etc.
Delete a Fillable Form Field in a Word Document using C#
Adding a fillable form field and deleting a fillable form field are the most important and frequently used features with reference to forms in word files. Now, let us take a look at how a fillable form field can be deleted using C# in your .NET applications. You can follow the following steps to delete a field:
- Load input word file using Document class
- Get specific fillable form field by its name
- Call Remove method
- Save output word file
The following code snippet is based on these steps which shows how to delete a fillable form field from word document with C#:
Concludingly, we have learned how to make or create fillable form fields in DOCX, or ord files. Moreover, we have also checked out how to delete or remove a form field from a word document. In case of any confusion, doubt, or query, you please write to us at Free Support Forum. We would love to assist you!