Generating Fillable PDF Forms from HTML in C#
Intake forms, applications, surveys, and onboarding paperwork all share a pattern: a recipient needs to fill in fields and return the document. A static PDF cannot do that, and printing, scanning, and re-keying wastes everyone's time. IronPDF generates fillable PDF forms in C#, either from HTML markup the team already has or by placing fields programmatically onto an existing document.
The Business Problem
A healthcare provider needs patient intake forms, an insurer needs applications, an HR team needs onboarding documents. Each should arrive as a PDF the recipient can complete on screen, ideally with known details already filled in. Building these by hand in a PDF editor does not scale, and maintaining a separate form layout duplicates the web version that often already exists.
Generating a Form from HTML
Enabling one rendering option turns standard HTML form elements into interactive PDF fields, so existing markup becomes a fillable document.
using IronPdf;
string formHtml = @"
<html><body>
<h2>Patient Intake</h2>
<form>
First name: <input type='text' name='firstname' value=''><br>
Address: <textarea name='address' rows='4' cols='50'></textarea><br>
Completed: <input type='checkbox' name='completed'><br>
Priority:
<select name='priority'>
<option value='high'>High</option>
<option value='low'>Low</option>
</select>
</form>
</body></html>";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(formHtml).SaveAs("intake-form.pdf");
using IronPdf;
string formHtml = @"
<html><body>
<h2>Patient Intake</h2>
<form>
First name: <input type='text' name='firstname' value=''><br>
Address: <textarea name='address' rows='4' cols='50'></textarea><br>
Completed: <input type='checkbox' name='completed'><br>
Priority:
<select name='priority'>
<option value='high'>High</option>
<option value='low'>Low</option>
</select>
</form>
</body></html>";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(formHtml).SaveAs("intake-form.pdf");
Imports IronPdf
Dim formHtml As String = "
<html><body>
<h2>Patient Intake</h2>
<form>
First name: <input type='text' name='firstname' value=''><br>
Address: <textarea name='address' rows='4' cols='50'></textarea><br>
Completed: <input type='checkbox' name='completed'><br>
Priority:
<select name='priority'>
<option value='high'>High</option>
<option value='low'>Low</option>
</select>
</form>
</body></html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.CreatePdfFormsFromHtml = True
renderer.RenderHtmlAsPdf(formHtml).SaveAs("intake-form.pdf")
Because each field has a name and a value, the same approach pre-fills a form from a database, so a renewal notice or application arrives with the recipient's details already populated and only the gaps left to complete.
Adding Fields to an Existing Document
When the base document did not come from HTML, such as a scanned form or a generated report needing an approval field, fields can be placed programmatically at exact coordinates.
using IronSoftware.Forms;
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Approval</h2>");
var textForm = new TextFormField("approver", "", pageIndex: 0, x: 100, y: 700, width: 150, height: 15);
pdf.Form.Add(textForm);
pdf.SaveAs("approval-form.pdf");
using IronSoftware.Forms;
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Approval</h2>");
var textForm = new TextFormField("approver", "", pageIndex: 0, x: 100, y: 700, width: 150, height: 15);
pdf.Form.Add(textForm);
pdf.SaveAs("approval-form.pdf");
Imports IronSoftware.Forms
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Approval</h2>")
Dim textForm As New TextFormField("approver", "", pageIndex:=0, x:=100, y:=700, width:=150, height:=15)
pdf.Form.Add(textForm)
pdf.SaveAs("approval-form.pdf")
Points to Plan For
- Enable the form flag: Without
CreatePdfFormsFromHtmlset to true, HTML form elements render as static visuals rather than fillable fields. This is the most common reason a form is not editable. - Programmatic fields are coordinate-based: Fields added through code use absolute x, y, width, height, and a page index, which is precise but makes layout your responsibility.
- Checkbox values: A checkbox uses "yes" and "no" rather than a boolean for its checked state.
- Creating is not securing: Generating a form does not lock or sign it. Apply passwords, permissions, or signatures separately when the document needs protection.
Result
With one option for HTML forms and coordinate-based fields for everything else, teams ship fillable, pre-fillable documents that recipients complete on screen, with no manual form building. Full field types and options are in the create PDF forms guide.
Frequently Asked Questions
How does IronPDF help in creating fillable PDF forms from HTML?
IronPDF allows you to generate fillable PDF forms from standard HTML form elements by enabling a rendering option. This transforms existing HTML markup into interactive PDF fields.
Can I use IronPDF to add fields to an existing PDF document?
Yes, IronPDF can programmatically add fields to an existing PDF document by specifying exact coordinates for each field, making it possible to customize forms according to specific layout requirements.
What is the advantage of using IronPDF for generating forms in a business context?
IronPDF automates the generation of fillable PDF forms from HTML, which is beneficial for businesses that need scalable solutions for forms like patient intake, insurance applications, and HR onboarding documents.
Is it possible to pre-fill form fields using IronPDF?
Yes, IronPDF allows pre-filling of form fields by using HTML form elements with specified names and values. This is useful for sending out applications or notices with recipient details already populated.
What are the considerations when adding form fields programmatically with IronPDF?
When adding form fields programmatically with IronPDF, it's important to use absolute coordinates for x, y, width, height, and page index to ensure precise placement of fields on the document.
What common issue might arise when creating fillable forms from HTML and how can it be resolved?
A common issue is that HTML form elements may render as static visuals instead of fillable fields. This can be resolved by ensuring the 'CreatePdfFormsFromHtml' option is enabled.
Can IronPDF secure the PDF forms it generates?
IronPDF does not secure PDF forms by default. After generating a form, you need to apply additional security measures like passwords, permissions, or digital signatures for document protection.
What types of form fields can be created using IronPDF?
IronPDF supports a wide range of form fields including text inputs, checkboxes, and dropdowns, among others. Detailed options can be found in their create PDF forms guide.

