Skip to footer content
USING IRONPDF

How to Create, Fill, and Extract PDF Forms in C# Using a .NET SDK

Interactive PDF forms turn static documents into data collection tools you can generate and process entirely in code. Whether building patient intake portals, automating loan applications, or generating thousands of pre-filled compliance forms from a database, IronPDF gives .NET developers a single, consistent API for every form task - creation, field population, data extraction, and bulk processing.

This guide walks through each of those tasks with working C# code examples you can drop straight into a .NET 10 project.

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 1 - IronPDF

How Do You Get Started with IronPDF?

IronPDF is available on NuGet and takes about a minute to add to any .NET project. Open the Package Manager Console in Visual Studio and run:

Install-Package IronPdf
Install-Package IronPdf
SHELL

You can also search for IronPdf in the NuGet Package Manager GUI, or add it from the .NET CLI with dotnet add package IronPdf. No additional runtime dependencies or configuration files are required - the library ships with everything it needs to render PDFs on Windows, Linux, macOS, Docker, and Kubernetes.

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 3 - Installation

The package targets .NET Framework 4.6.2+ and all modern .NET versions including .NET 8, .NET 9, and .NET 10. Once the package is installed, add using IronPdf; at the top of your file and you are ready to generate your first PDF form.

Cross-platform deployment flexibility matters in production environments. IronPDF runs consistently whether your application targets Windows Server, a Linux container, or an Azure Function App - the same code produces the same output across every environment.

What Makes PDF Forms Work? Understanding AcroForms

Before writing code, it helps to understand what you are building. The AcroForm specification - part of the PDF standard since 1998 - defines interactive form fields that any standard PDF viewer can display and complete. AcroForms support text fields, checkboxes, radio buttons, dropdown lists, list boxes, and signature fields.

AcroForms are the format IronPDF creates and reads. Unlike XFA forms (an older, proprietary Adobe format), AcroForms work across Adobe Reader, browser-based PDF viewers, and mobile apps without compatibility issues. When you create PDF forms with IronPDF, the output is a standards-compliant AcroForm PDF that any viewer can open.

Each form field carries a name, a type, and a value. The name is the key you use when reading or writing data programmatically. Field names must be unique within a document - if you populate a form by name and the field name does not match exactly, the write silently has no effect, which is a common source of bugs when filling forms from a database schema.

Field types determine what values are accepted. Text fields take any string. Checkboxes accept "Yes" or "No". Radio buttons accept the string value of the selected option. Dropdowns accept the string value of the selected item, which must be one of the options defined when the field was created.

How Do You Create a PDF Form from HTML?

The fastest way to build a fillable PDF form is to write it as standard HTML and convert it. Every HTML form element maps directly to its AcroForm equivalent: <input type="text"> becomes a text field, <input type="checkbox"> becomes a checkbox, <select> becomes a dropdown, and <textarea> becomes a multiline text field.

Enable form creation by setting CreatePdfFormsFromHtml = true on the renderer's RenderingOptions. Without that flag, HTML form elements render as static visual content - you can see them in the PDF, but they are not interactive fields.

using IronPdf;

// HTML with form elements for PDF generation
string formHtml = @"
<html>
<body>
    <h2>Customer Registration</h2>
    <form>
        <label>Full Name:</label><br/>
        <input type='text' name='fullName'><br/>
        <label>Email Address:</label><br/>
        <input type='email' name='email'><br/>
        <label>Account Type:</label><br/>
        <select name='accountType'>
            <option value='personal'>Personal</option>
            <option value='business'>Business</option>
        </select><br/>
        <label>Newsletter:</label><br/>
        <input type='checkbox' name='newsletter' value='yes'>Subscribe<br/>
        <label>Comments:</label><br/>
        <textarea name='comments' rows='4' style='width:300px'></textarea>
    </form>
</body>
</html>";

// Enable form field generation from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

// Render and save the PDF with interactive fields
PdfDocument pdf = renderer.RenderHtmlAsPdf(formHtml);
pdf.SaveAs("registration-form.pdf");
using IronPdf;

// HTML with form elements for PDF generation
string formHtml = @"
<html>
<body>
    <h2>Customer Registration</h2>
    <form>
        <label>Full Name:</label><br/>
        <input type='text' name='fullName'><br/>
        <label>Email Address:</label><br/>
        <input type='email' name='email'><br/>
        <label>Account Type:</label><br/>
        <select name='accountType'>
            <option value='personal'>Personal</option>
            <option value='business'>Business</option>
        </select><br/>
        <label>Newsletter:</label><br/>
        <input type='checkbox' name='newsletter' value='yes'>Subscribe<br/>
        <label>Comments:</label><br/>
        <textarea name='comments' rows='4' style='width:300px'></textarea>
    </form>
</body>
</html>";

// Enable form field generation from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

// Render and save the PDF with interactive fields
PdfDocument pdf = renderer.RenderHtmlAsPdf(formHtml);
pdf.SaveAs("registration-form.pdf");
$vbLabelText   $csharpLabel

Each HTML input's name attribute becomes the field name in the PDF. That name is what you use later when reading or writing field values programmatically. Choose names that match your data model - if you are going to populate this form from a database object, name the fields after the object's properties.

Output

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 4 - PDF Output

Text inputs and textareas render as editable text fields. Radio buttons with matching name attributes group together so only one can be selected. Checkboxes render as toggleable fields. The resulting PDF opens in any standard viewer with all form fields ready to complete.

This HTML-based approach works well when form designs already exist as web pages, when your team prefers maintaining forms in markup, or when you need to generate forms that match your application's existing HTML templates precisely. The renderer handles all PDF specification details.

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 5 - Features

How Do You Add Form Fields to a PDF Programmatically?

When precise coordinate control is required, or when you are adding form fields to an existing PDF document, the programmatic form field API gives you direct control over every field's position, size, and default value.

Create field objects with explicit page coordinates. The origin (0, 0) is at the bottom-left corner of the page, with x increasing right and y increasing up - the same coordinate system used throughout the PDF specification.

using IronPdf;
using IronSoftware.Forms;

// Generate a base PDF document to add fields to
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf(
    "<h1>Application Form</h1><p>Please complete all fields below.</p>");

// Text field: name, default value, page index, x, y, width, height
var nameField = new TextFormField("applicantName", "", 0, 50, 700, 200, 20);
pdf.Form.Add(nameField);

// Checkbox field with default unchecked state
var termsCheckbox = new CheckboxFormField("agreeTerms", "no", 0, 50, 650, 15, 15);
pdf.Form.Add(termsCheckbox);

// Dropdown with a defined list of options
var departmentCombo = new ComboboxFormField(
    "department", "", 0, 50, 600, 150, 20,
    new List<string> { "Engineering", "Marketing", "Sales", "Support" });
pdf.Form.Add(departmentCombo);

// Save the output document
pdf.SaveAs("application-with-fields.pdf");
using IronPdf;
using IronSoftware.Forms;

// Generate a base PDF document to add fields to
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf(
    "<h1>Application Form</h1><p>Please complete all fields below.</p>");

// Text field: name, default value, page index, x, y, width, height
var nameField = new TextFormField("applicantName", "", 0, 50, 700, 200, 20);
pdf.Form.Add(nameField);

// Checkbox field with default unchecked state
var termsCheckbox = new CheckboxFormField("agreeTerms", "no", 0, 50, 650, 15, 15);
pdf.Form.Add(termsCheckbox);

// Dropdown with a defined list of options
var departmentCombo = new ComboboxFormField(
    "department", "", 0, 50, 600, 150, 20,
    new List<string> { "Engineering", "Marketing", "Sales", "Support" });
pdf.Form.Add(departmentCombo);

// Save the output document
pdf.SaveAs("application-with-fields.pdf");
$vbLabelText   $csharpLabel

TextFormField creates a single-line text input. CheckboxFormField places a toggleable checkbox. ComboboxFormField creates a dropdown restricted to the provided option list. Each class exposes additional properties for setting tab order, tooltip text, read-only state, and required field flags.

Both approaches - HTML conversion and programmatic field creation - can be combined. Generate the base layout from HTML for efficient template control, then add specialized fields with precise positioning using the API. The fill and edit forms guide covers the full range of available field types.

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 6 - PDF Forms .NET SDK - IronPDF

How Do You Fill an Existing PDF Form?

Many workflows start with a pre-existing PDF form - a government template, a vendor contract, or a standardized application your organization receives from partners. Filling these forms programmatically lets you automate document generation without recreating the original design.

Load the existing PDF with PdfDocument.FromFile, locate each field by its name using FindFormField, and assign a value to the field's Value property.

using IronPdf;

// Load the existing PDF containing AcroForm fields
PdfDocument pdf = PdfDocument.FromFile("existing-application.pdf");

// Fill text fields by exact field name
var nameField = pdf.Form.FindFormField("applicantName");
nameField.Value = "Sarah Johnson";

var emailField = pdf.Form.FindFormField("email");
emailField.Value = "sarah.johnson@example.com";

// Set checkbox and radio button values
var termsField = pdf.Form.FindFormField("agreeTerms");
termsField.Value = "Yes";

var accountTypeField = pdf.Form.FindFormField("accountType");
accountTypeField.Value = "business";

// Set dropdown selection to one of its defined options
var departmentField = pdf.Form.FindFormField("department");
departmentField.Value = "Engineering";

// Save the completed form
pdf.SaveAs("completed-application.pdf");
using IronPdf;

// Load the existing PDF containing AcroForm fields
PdfDocument pdf = PdfDocument.FromFile("existing-application.pdf");

// Fill text fields by exact field name
var nameField = pdf.Form.FindFormField("applicantName");
nameField.Value = "Sarah Johnson";

var emailField = pdf.Form.FindFormField("email");
emailField.Value = "sarah.johnson@example.com";

// Set checkbox and radio button values
var termsField = pdf.Form.FindFormField("agreeTerms");
termsField.Value = "Yes";

var accountTypeField = pdf.Form.FindFormField("accountType");
accountTypeField.Value = "business";

// Set dropdown selection to one of its defined options
var departmentField = pdf.Form.FindFormField("department");
departmentField.Value = "Engineering";

// Save the completed form
pdf.SaveAs("completed-application.pdf");
$vbLabelText   $csharpLabel

FindFormField locates fields by the name assigned during form creation. Field name matching is case-sensitive and exact - "applicantName" and "ApplicantName" are different fields. If you are filling a third-party form and are unsure of field names, iterate over pdf.Form to print each field's name before trying to fill by name.

Input

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 7 - Sample PDF Input

Output

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 8 - Filled PDF Output

Different field types require appropriate value formats. Text fields accept any string. Checkboxes accept "Yes" or "No". Radio buttons accept the string value of the desired option. Dropdowns accept the string value of one of the defined options - setting a value that is not in the option list has no effect.

When processing forms with many fields, iterate over pdf.Form directly rather than calling FindFormField repeatedly. Iteration is more efficient for bulk operations and avoids repeated linear searches through the field collection.

How Do You Read and Extract Form Field Data?

Extracting form data from submitted PDFs is the reverse operation: load a completed form, then read each field's name and current value for downstream processing. This pattern powers automated intake workflows where users complete a PDF form, upload it, and the application processes the data without manual data entry.

using IronPdf;

// Load the completed, submitted PDF form
PdfDocument pdf = PdfDocument.FromFile("submitted-form.pdf");

// Iterate all fields to extract names, values, and types
Console.WriteLine("Form Data Extraction:");
Console.WriteLine("----------------------");
foreach (var field in pdf.Form)
{
    Console.WriteLine($"Field: {field.Name}");
    Console.WriteLine($"Value: {field.Value}");
    Console.WriteLine($"Type:  {field.GetType().Name}");
    Console.WriteLine();
}

// Or retrieve specific fields for targeted processing
var customerName  = pdf.Form.FindFormField("applicantName")?.Value ?? "Not provided";
var customerEmail = pdf.Form.FindFormField("email")?.Value ?? "Not provided";
Console.WriteLine($"Customer: {customerName} ({customerEmail})");
using IronPdf;

// Load the completed, submitted PDF form
PdfDocument pdf = PdfDocument.FromFile("submitted-form.pdf");

// Iterate all fields to extract names, values, and types
Console.WriteLine("Form Data Extraction:");
Console.WriteLine("----------------------");
foreach (var field in pdf.Form)
{
    Console.WriteLine($"Field: {field.Name}");
    Console.WriteLine($"Value: {field.Value}");
    Console.WriteLine($"Type:  {field.GetType().Name}");
    Console.WriteLine();
}

// Or retrieve specific fields for targeted processing
var customerName  = pdf.Form.FindFormField("applicantName")?.Value ?? "Not provided";
var customerEmail = pdf.Form.FindFormField("email")?.Value ?? "Not provided";
Console.WriteLine($"Customer: {customerName} ({customerEmail})");
$vbLabelText   $csharpLabel

The Form property exposes an enumerable collection of all fields in the document. Each field object provides its Name, current Value, and type information. Generic form processors use this pattern to handle any PDF form structure without hard-coded field names.

Output

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 9 - Console Output

The null-conditional operator ?. on FindFormField handles cases where an expected field is absent - useful when processing forms from multiple sources that may have slightly different field structures. Always supply a fallback value or null check rather than assuming the field exists.

Extracted data integrates directly with Entity Framework or ADO.NET for database writes, JSON serialization for API responses, and CSV generation for reporting. Pair IronPDF with IronOCR when you also need to extract data from scanned or image-based form submissions where fields were not filled digitally.

How Do You Generate Personalized Forms at Scale?

The highest-volume use case for PDF form automation is batch generation - producing hundreds or thousands of forms pre-filled with data from a database, API, or CSV file. A simple loop handles this without any extra infrastructure.

using IronPdf;

// Retrieve customer records from your data source
var customers = GetCustomersFromDatabase();

ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

foreach (var customer in customers)
{
    // Build an HTML template with static data pre-filled and interactive fields for user input
    string formHtml = $@"
    <html><body>
        <h2>Annual Review Form</h2>
        <p>Customer: {customer.Name}</p>
        <p>Account:  {customer.AccountNumber}</p>
        <label>Satisfaction Rating (1-5):</label><br/>
        <input type='text' name='rating' maxlength='1'><br/>
        <label>Feedback:</label><br/>
        <textarea name='feedback' rows='5' style='width:100%'></textarea>
    </body></html>";

    PdfDocument pdf = renderer.RenderHtmlAsPdf(formHtml);
    pdf.SaveAs($"review-form-{customer.AccountNumber}.pdf");
}
using IronPdf;

// Retrieve customer records from your data source
var customers = GetCustomersFromDatabase();

ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

foreach (var customer in customers)
{
    // Build an HTML template with static data pre-filled and interactive fields for user input
    string formHtml = $@"
    <html><body>
        <h2>Annual Review Form</h2>
        <p>Customer: {customer.Name}</p>
        <p>Account:  {customer.AccountNumber}</p>
        <label>Satisfaction Rating (1-5):</label><br/>
        <input type='text' name='rating' maxlength='1'><br/>
        <label>Feedback:</label><br/>
        <textarea name='feedback' rows='5' style='width:100%'></textarea>
    </body></html>";

    PdfDocument pdf = renderer.RenderHtmlAsPdf(formHtml);
    pdf.SaveAs($"review-form-{customer.AccountNumber}.pdf");
}
$vbLabelText   $csharpLabel

The HTML template embeds static customer data directly, so the recipient sees their name and account number pre-printed, and provides interactive fields for the data they need to supply. Batch processing hundreds of records completes in seconds rather than the hours manual preparation would require.

The loop structure works with any data source: Entity Framework queries, API responses, or CSV imports. Each iteration produces a complete, ready-to-distribute PDF customized for that record. For high-throughput scenarios, use async/await with Task.WhenAll to render forms in parallel - IronPDF's RenderHtmlAsPdfAsync method supports fully asynchronous rendering.

After batch generation, forms are commonly packaged into a ZIP archive for distribution using IronZIP, sent via email integration, uploaded to cloud storage, or routed to an electronic signature platform for binding completion.

How Do You Flatten or Lock PDF Forms After Completion?

Once a form is fully completed and validated, you often need to lock it so the values can no longer be edited. Flattening converts all interactive form fields into static, non-editable visual content while preserving the exact appearance of the completed form.

using IronPdf;

// Load a completed, signed form
PdfDocument pdf = PdfDocument.FromFile("completed-application.pdf");

// Flatten all form fields - converts interactive fields to static content
pdf.Form.Flatten();

// Save the locked, non-editable version
pdf.SaveAs("locked-application.pdf");
using IronPdf;

// Load a completed, signed form
PdfDocument pdf = PdfDocument.FromFile("completed-application.pdf");

// Flatten all form fields - converts interactive fields to static content
pdf.Form.Flatten();

// Save the locked, non-editable version
pdf.SaveAs("locked-application.pdf");
$vbLabelText   $csharpLabel

Flattening is the correct approach for archiving completed forms, generating PDF/A compliant documents for long-term storage, and producing final copies for distribution. After flattening, the form data is still visible but cannot be modified. The PDF flatten guide covers additional flatten options including selective field flattening.

For scenarios requiring legally binding completion, IronPDF also supports digital signatures, which cryptographically bind the signer's identity to the document. Digital signatures and form flattening serve different purposes - signatures prove authenticity, flattening prevents modification.

What Are Your Next Steps?

PDF forms in .NET cover four core operations: creating forms from HTML or through the API, filling existing forms from data sources, extracting submitted data, and batch generating personalized copies at scale. IronPDF handles all four through a consistent API, with the same code running on Windows, Linux, macOS, and inside containers.

The Create PDF Forms how-to guide covers every available field type with code examples. The Fill and Edit Forms guide goes deeper on bulk field updates, radio button groups, and list box handling. The IronPDF documentation hub provides the complete API reference and advanced topics including multi-page forms, form field validation, and performance tuning for high-volume pipelines.

Start a free trial to explore PDF form capabilities in your own project, or review licensing options for production deployment.

PDF Forms .NET SDK: Create Fillable PDFs in C# Using IronPDF: Image 10 - Licensing

Frequently Asked Questions

What PDF form standard does IronPDF use?

IronPDF creates and reads AcroForms - the interactive form standard defined in the PDF specification since 1998. AcroForms are supported by Adobe Reader, browser-based PDF viewers, and mobile apps, unlike the older XFA format which has limited compatibility.

How do you enable form field creation from HTML in IronPDF?

Set `renderer.RenderingOptions.CreatePdfFormsFromHtml = true` before calling `RenderHtmlAsPdf`. Without this flag, HTML form elements render as static visual content rather than interactive AcroForm fields.

How do you fill a specific field in an existing PDF form?

Load the PDF with `PdfDocument.FromFile`, call `pdf.Form.FindFormField("fieldName")` to retrieve the field object, then assign a string to its `Value` property. Field name matching is case-sensitive. Save the result with `pdf.SaveAs`.

How do you extract all form field values from a submitted PDF?

Iterate over `pdf.Form` with `foreach (var field in pdf.Form)` and read each field's `Name` and `Value` properties. For targeted extraction, use `pdf.Form.FindFormField("name")?.Value` with the null-conditional operator to handle missing fields safely.

Can IronPDF generate hundreds of forms from a database in a loop?

Yes. Create a `ChromePdfRenderer` with `CreatePdfFormsFromHtml = true`, iterate over your data records, build an HTML string per record, call `RenderHtmlAsPdf`, and save each result. For high throughput, use `RenderHtmlAsPdfAsync` with `Task.WhenAll` for parallel rendering.

What does flattening a PDF form do?

Flattening converts all interactive form fields into static, non-editable visual content while preserving the exact appearance of the filled form. Call `pdf.Form.Flatten()` then save. The result is suitable for archival, PDF/A compliance, and distribution where field editing must be prevented.

Does IronPDF work on Linux and in Docker containers?

Yes. IronPDF runs on Windows, Linux, macOS, Docker, and Kubernetes. The same C# code produces the same PDF output on all platforms. See the IronPDF Linux and Docker guides in the documentation for platform-specific configuration.

What platforms and .NET versions does IronPDF support for PDF forms?

IronPDF supports .NET Framework 4.6.2 and above, and all modern .NET versions including .NET 6, .NET 7, .NET 8, .NET 9, and .NET 10. It also supports ASP.NET, ASP.NET Core, Blazor Server, Azure Functions, and MAUI applications.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me