So, at that moment, we discover that there is a library called iText. It’s a very complete and useful library and already exists several components using it, so we thought that would be rather easy to accomplish and develop this new component.

Well but, of course, there was a tiny issue in that scenario. The company didn’t want to pay for any license and didn’t want to add more costs to the project. So, we had to start looking if there was any library that could manipulate PDF files, and specifically, if it could fill a fillable PDF file.

After a few searches, we discovered the PDFsharp library.

“PDFsharp is an Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer.”

For more information click here.

Introducing PDFSharp — Fillable PDF

Using this component, you can automatically fill a fillable PDF form. At this moment, it only supports the following input types: Text (TXT), Combobox (CBX) and Checkbox (CHK). The basic use case scenario is:

  1. Insert the PDF file that you want to fill;
  2. Fetch all the fillable inputs in the pdf;
  3. Fill them with the correct information;
  4. Download the new PDF file filled.

The extension only has a structure and two server actions:

Structure Fields

The structure Fields has three attributes that define each fillable input:

  1. Name, which matches the name of the input (set when a fillable pdf form is created);
  2. Type, which matches the type of input (TXT, CBX or CHK);
  3. Value, which matches the value already inserted (If the input is empty, it returns an empty value).
 FormFields_Get Action
FormFields_Get Action

The action FormFields_Get receives as an input a Binary Data and, as an output, it returns all the fillable inputs in the Binary Data that you inserted.

 FormFields_SetValues Action
FormFields_SetValues Action

The action FormFields_SetValues receives as an input a binary data and a list of Fields records. As an output, it returns the PDF file already filled with the correct information.

How to test and watch the functionalities

I created a simple test page. On that page, you will see a few instructions and reminders.

First, you can download the PDF file that I’m using as an example. It was a pdf that I created using Foxit, but you can create that file on any other program.

 Example of a Fillable PDF file
Example of a Fillable PDF file

(Note: I strongly advise you to create a fillable PDF file using Foxit or Adobe, because I only tested this component with files created with these two programs. To create a fillable PDF file using these programs you have to pay, it’s not available on the free functionalities.)

Second, by clicking the button “Get Fields”, the list of all inputs available are shown in the list.

 List of all fillable inputs on that file
List of all fillable inputs on that file.

hird, you can set a value by each input, by clicking the button “Set Field” on each row, or you can insert the new information on each input and then click “Set Fields” to fill and download the new PDF file.

To define new values, the rules change for each type:

  1. Text Type — You can insert any value.
  2. Combo box — You can insert one of the options of the combo box, in this case, Portuguese, English or Deutsch, without the “(“ and “)”. It’s important that the text you insert has to match one of the options available in the combo box.
  3. Checkbox — You can insert “True” if you want to check that option, “False” if not.

Check here an example of the file filled already with the values that I inserted on that page:

Applicant's Interview Notes Form Example
Applicant’s Interview Notes Form Example

And that’s it. This is still a work in progress and in the future can have more options and settings on the final PDF file. You can check and download the component by clicking here.