How to Insert Fillable Fields in PDF in C#

This how-to guide explains how to insert fillable fields in PDF in C#. It has all the ingredients to establish the environment and write a preliminary application that can be used to add form fields to PDF in C#. You will have full control over the placement of the control at a particular position on a specified page.

Steps to Add Fillable Fields to PDF in C#

  1. Set the environment to add Aspose.PDF for .NET to the application to add a text field
  2. Create a FormEditor class object for binding the target PDF file
  3. Bind the PDF file with the FormEditor object for adding controls to it
  4. Add a textbox on the first page of the target PDF file at a specified position using the AddField method
  5. Set the data entry limit for the newly added text box
  6. Save the resultant PDF file

These steps outline the process to add text field to PDF in C#. The process is initiated by creating an object of FormEditor class as it contains all the basic methods and properties to accomplish this task like the target PDF file is bound with it and then the AddField method of this class is used to add a textbox on a particular page and location. You can set different properties of the newly added control e.g. for the textbox you may set the maximum text allowed.

Code to Add Editable Field to PDF in C#

The above code demonstrates the process of how to add fillable fields in PDF in C#. The FormEditor class is used that supports adding a variety of form controls to a PDF page like textbox, checkbox, pushbutton, multiline text, image, data time, and radio control to name a few. Each control is supposed to have different properties therefore appropriate properties from the FormEditor class are used like the field limit is set here.

This short guide has explained the task to add fields to PDF in C#. If you want to learn the process to flatten the form fields in a PDF file, refer to the article on how to flatten PDF form fields in C#.

 English