How to save fillable pdf asp net c sharp


ASP.NET is a popular language used for developing web applications. In this article, we will explore how to save a fillable PDF using ASP.NET and C#.

Step 1: Create a PDF Form

The first step is to create a fillable PDF form that can data into. You can use Adobe Acrobat or any other PDF editing software to create the form. Make sure to add form fields such as text boxes, checkboxes, and dropdown menus.

Step 2: Upload the PDF Form

Next, you need to upload the PDF form to your ASP.NET web application. You can do this by adding the PDF file to your project's folder or by using a file upload control to allow users to upload the form.

Step 3: Process the Form Data

Once the user submits the form, you need to process the form data in your ASP.NET code. You can use the iTextSharp library to read the form fields and the data.

// Example code to process the form data
using iTextSharp.text;
using iTextSharp.text.pdf;

string filePath = "path/to/your/pdf/form.pdf";

// Open the PDF file
PdfReader reader = new PdfReader(filePath);
PdfStamper stamper = new PdfStamper(reader, new FileStream("path/to/save/filled/form.pdf", FileMode.Create));

// Get the form fields
AcroFields formFields = stamper.AcroFields;

// Set the form  values
formFields.SetField("name", "John Doe");
formFields.SetField("email", "");
formFields.SetField("checkbox", "Yes");

// Flatten the form fields
stamper.FormFlattening = true;

//  the stamper and reader

In the above example, we first open the PDF file using the PdfReader class. Then, we create a PdfStamper object to the PDF. We retrieve the form fields using the AcroFields property of the stamper. We set the values of the form fields using the SetField method. Finally, we flatten the form fields to make them uneditable and close the stamper and reader.

Step 4: Save the Filled PDF

processing the form data, you can save the filled PDF to a desired . In the example code above, we save the filled form as “path/to/save/filled/form.pdf”. You can customize the file path and name according to your requirements.


In this article, we have discussed how to save a fillable PDF using ASP.NET and C#. By following the steps outlined above and using the iTextSharp library, you can easily process and save filled PDF forms in your ASP.NET web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents