Cómo Crear Formularios PDF en C# Usando IronPDF

How to Create PDF Forms

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF offers a comprehensive set of form creation capabilities. It provides support for various types of form elements, including input fields, text areas, checkboxes, comboboxes, radio buttons, and image form. With IronPDF, you can easily generate dynamic PDF forms that allow users to interact with the document by filling out form fields, making selections, and saving changes. This enables you to create interactive and user-friendly PDF forms for a wide range of applications and scenarios.

Quickstart: Build Your First PDF Form with IronPDF

Get started fast with IronPDF to create interactive, fillable PDF forms. This quick guide shows you how to dynamically generate a PDF with form fields using simple C# code. By leveraging IronPDF's robust API, you can create text inputs, checkboxes, and more to enhance user interaction with minimal effort. Follow along to see how easy it is to define form elements and save your document. Perfect for developers eager to implement PDF forms quickly and efficiently.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    new IronPdf.ChromePdfRenderer { RenderingOptions = { CreatePdfFormsFromHtml = true } }
        .RenderHtmlAsPdf("<html><body><form>First name: <input type='text' name='firstname' value=''>Last name: <input type='text' name='lastname' value=''></form></body></html>")
        .SaveAs("editableForm.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer


Create Forms

IronPDF effortlessly creates PDF documents with embedded form fields of various types. By adding dynamic form elements to an otherwise static PDF document, you can enhance its flexibility and interactivity.

Text Area and Input Forms

Render From HTML

You can easily create text area and input forms to capture user input within your PDF documents. Text area forms provide ample space for displaying and capturing larger amounts of text, while input forms allow users to enter specific values or responses.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-input-textarea.cs
using IronPdf;

// Input and Text Area forms HTML
string FormHtml = @"
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <form>
            First name: <br> <input type='text' name='firstname' value=''> <br>
            Last name: <br> <input type='text' name='lastname' value=''> <br>
            Address: <br> <textarea name='address' rows='4' cols='50'></textarea>
        </form>
    </body>
</html>
";

// Instantiate Renderer
ChromePdfRenderer Renderer = new ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("textAreaAndInputForm.pdf");
Imports IronPdf

' Input and Text Area forms HTML
Private FormHtml As String = "
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <form>
            First name: <br> <input type='text' name='firstname' value=''> <br>
            Last name: <br> <input type='text' name='lastname' value=''> <br>
            Address: <br> <textarea name='address' rows='4' cols='50'></textarea>
        </form>
    </body>
</html>
"

' Instantiate Renderer
Private Renderer As New ChromePdfRenderer()
Renderer.RenderingOptions.CreatePdfFormsFromHtml = True

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("textAreaAndInputForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Add Text Form via Code

The above code example talks about rendering HTML that contains text areas and input forms. However, it is also possible to add a text form field through code. First, instantiate a TextFormField object with the required parameters. Next, use the Add method of the Form property to add the created form.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-add-input-textarea.cs
using IronPdf;
using IronSoftware.Forms;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>");

// Configure required parameters
string name = "firstname";
string value = "first name";
uint pageIndex = 0;
double x = 100;
double y = 700;
double width = 50;
double height = 15;

// Create text form field
var textForm = new TextFormField(name, value, pageIndex, x, y, width, height);

// Add form
pdf.Form.Add(textForm);

pdf.SaveAs("addTextForm.pdf");
Imports IronPdf
Imports IronSoftware.Forms

' Instantiate ChromePdfRenderer
Private renderer As New ChromePdfRenderer()

Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>")

' Configure required parameters
Private name As String = "firstname"
Private value As String = "first name"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 700
Private width As Double = 50
Private height As Double = 15

' Create text form field
Private textForm = New TextFormField(name, value, pageIndex, x, y, width, height)

' Add form
pdf.Form.Add(textForm)

pdf.SaveAs("addTextForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Having a text form field in a PDF without a label might not be very meaningful. To enhance its usefulness, you should add text to the PDF as a label for the form field. IronPdf has you covered. You can achieve this by using the DrawText method. Learn more about How to Draw Text and Bitmap on PDFs.


Checkbox and Combobox Forms

Render From HTML

Similarly, checkbox and combobox forms can be created by rendering from an HTML string, file, or web URL that contains checkboxes and comboboxes. Set the CreatePdfFormsFromHtml property to true to enable the creation of these forms.

Combobox forms provide users with a dropdown selection of options. Users can choose from the available options, offering valuable input within the PDF documents.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-checkbox-combobox.cs
using IronPdf;

// Input and Text Area forms HTML
string FormHtml = @"
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <h2>Task Completed</h2>
        <label>
            <input type='checkbox' id='taskCompleted' name='taskCompleted'> Mark task as completed
        </label>

        <h2>Select Priority</h2>
        <label for='priority'>Choose priority level:</label>
        <select id='priority' name='priority'>
            <option value='high'>High</option>
            <option value='medium'>Medium</option>
            <option value='low'>Low</option>
        </select>
    </body>
</html>
";

// Instantiate Renderer
ChromePdfRenderer Renderer = new ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("checkboxAndComboboxForm.pdf");
Imports IronPdf

' Input and Text Area forms HTML
Private FormHtml As String = "
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <h2>Task Completed</h2>
        <label>
            <input type='checkbox' id='taskCompleted' name='taskCompleted'> Mark task as completed
        </label>

        <h2>Select Priority</h2>
        <label for='priority'>Choose priority level:</label>
        <select id='priority' name='priority'>
            <option value='high'>High</option>
            <option value='medium'>Medium</option>
            <option value='low'>Low</option>
        </select>
    </body>
</html>
"

' Instantiate Renderer
Private Renderer As New ChromePdfRenderer()
Renderer.RenderingOptions.CreatePdfFormsFromHtml = True

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("checkboxAndComboboxForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Add Form via Code

Checkbox

To add a checkbox form field, first instantiate a CheckboxFormField object with the required parameters. The value parameter of the checkbox will determine whether the form should be checked or not, with "no" value for not checked and "yes" value for checked. Finally, use the Add method of the Form property to add the created form.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-add-checkbox.cs
using IronPdf;
using IronSoftware.Forms;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Checkbox Form Field</h2>");

// Configure required parameters
string name = "checkbox";
string value = "no";
uint pageIndex = 0;
double x = 100;
double y = 700;
double width = 15;
double height = 15;

// Create checkbox form field
var checkboxForm = new CheckboxFormField(name, value, pageIndex, x, y, width, height);

// Add form
pdf.Form.Add(checkboxForm);

pdf.SaveAs("addCheckboxForm.pdf");
Imports IronPdf
Imports IronSoftware.Forms

' Instantiate ChromePdfRenderer
Private renderer As New ChromePdfRenderer()

Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Checkbox Form Field</h2>")

' Configure required parameters
Private name As String = "checkbox"
Private value As String = "no"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 700
Private width As Double = 15
Private height As Double = 15

' Create checkbox form field
Private checkboxForm = New CheckboxFormField(name, value, pageIndex, x, y, width, height)

' Add form
pdf.Form.Add(checkboxForm)

pdf.SaveAs("addCheckboxForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Combobox

To add a combobox form field, first instantiate a ComboboxFormField object with the required parameters. Similar to the checkbox form, the value parameter of the combobox determines which choice will be selected. Finally, use the Add method of the Form property to add the created form.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-add-combobox.cs
using IronPdf;
using IronSoftware.Forms;
using System.Collections.Generic;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Combobox Form Field</h2>");

// Configure required parameters
string name = "combobox";
string value = "Car";
uint pageIndex = 0;
double x = 100;
double y = 700;
double width = 60;
double height = 15;
var choices = new List<string>() { "Car", "Bike", "Airplane" };

// Create combobox form field
var comboboxForm = new ComboboxFormField(name, value, pageIndex, x, y, width, height, choices);

// Add form
pdf.Form.Add(comboboxForm);

pdf.SaveAs("addComboboxForm.pdf");
Imports IronPdf
Imports IronSoftware.Forms
Imports System.Collections.Generic

' Instantiate ChromePdfRenderer
Private renderer As New ChromePdfRenderer()

Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Combobox Form Field</h2>")

' Configure required parameters
Private name As String = "combobox"
Private value As String = "Car"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 700
Private width As Double = 60
Private height As Double = 15
Private choices = New List(Of String)() From {"Car", "Bike", "Airplane"}

' Create combobox form field
Private comboboxForm = New ComboboxFormField(name, value, pageIndex, x, y, width, height, choices)

' Add form
pdf.Form.Add(comboboxForm)

pdf.SaveAs("addComboboxForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document


Radio buttons Forms

Render From HTML

When working with radio button forms in IronPDF, radio buttons of the same group are contained within one form object. You can retrieve that form by inputting its name into the FindFormField method. If any of the radio choices is selected, the Value property of that form will have that value; otherwise, it will have a value of 'None'.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-radiobutton.cs
using IronPdf;

// Radio buttons HTML
string FormHtml = @"
<html>
    <body>
        <h2>Editable PDF Form</h2>
        Choose your preferred travel type: <br>
        <input type='radio' name='traveltype' value='Bike'>
        Bike <br>
        <input type='radio' name='traveltype' value='Car'>
        Car <br>
        <input type='radio' name='traveltype' value='Airplane'>
        Airplane
    </body>
</html>
";

// Instantiate Renderer
ChromePdfRenderer Renderer = new ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("radioButtomForm.pdf");
Imports IronPdf

' Radio buttons HTML
Private FormHtml As String = "
<html>
    <body>
        <h2>Editable PDF Form</h2>
        Choose your preferred travel type: <br>
        <input type='radio' name='traveltype' value='Bike'>
        Bike <br>
        <input type='radio' name='traveltype' value='Car'>
        Car <br>
        <input type='radio' name='traveltype' value='Airplane'>
        Airplane
    </body>
</html>
"

' Instantiate Renderer
Private Renderer As New ChromePdfRenderer()
Renderer.RenderingOptions.CreatePdfFormsFromHtml = True

Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("radioButtomForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Add Radio Form via Code

Similarly, a radio button form field can also be added through code. First, instantiate a RadioFormField object with the required parameters. Next, use the Add method of the Form property to add the created form.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-add-radiobutton.cs
using IronPdf;
using IronSoftware.Forms;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>");

// Configure required parameters
string name = "choice";
string value = "yes";
uint pageIndex = 0;
double x = 100;
double y = 700;
double width = 15;
double height = 15;

// Create the first radio form
var yesRadioform = new RadioFormField(name, value, pageIndex, x, y, width, height);

value = "no";
x = 200;

// Create the second radio form
var noRadioform = new RadioFormField(name, value, pageIndex, x, y, width, height);

pdf.Form.Add(yesRadioform);
pdf.Form.Add(noRadioform);

pdf.SaveAs("addRadioForm.pdf");
Imports IronPdf
Imports IronSoftware.Forms

' Instantiate ChromePdfRenderer
Private renderer As New ChromePdfRenderer()

Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>")

' Configure required parameters
Private name As String = "choice"
Private value As String = "yes"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 700
Private width As Double = 15
Private height As Double = 15

' Create the first radio form
Private yesRadioform = New RadioFormField(name, value, pageIndex, x, y, width, height)

value = "no"
x = 200

' Create the second radio form
Dim noRadioform = New RadioFormField(name, value, pageIndex, x, y, width, height)

pdf.Form.Add(yesRadioform)
pdf.Form.Add(noRadioform)

pdf.SaveAs("addRadioForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

As a final touch, use the DrawText method to add labels for the radio buttons. Learn more about How to Draw Text and Bitmap on PDFs.


Image Forms via Code

Image form field can only be added through code. First, instantiate a ImageFormField object with the required parameters. Next, use the Add method of the Form property to add the created form.

:path=/static-assets/pdf/content-code-examples/how-to/create-forms-add-image.cs
using IronPdf;
using IronSoftware.Forms;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>");

// Configure required parameters
string name = "image1";
uint pageIndex = 0;
double x = 100;
double y = 600;
double width = 200;
double height = 200;

// Create the image form
ImageFormField imageForm = new ImageFormField(name, pageIndex, x, y, width, height);

pdf.Form.Add(imageForm);

pdf.SaveAs("addImageForm.pdf");
Imports IronPdf
Imports IronSoftware.Forms

' Instantiate ChromePdfRenderer
Private renderer As New ChromePdfRenderer()

Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h2>Editable PDF Form</h2>")

' Configure required parameters
Private name As String = "image1"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 600
Private width As Double = 200
Private height As Double = 200

' Create the image form
Private imageForm As New ImageFormField(name, pageIndex, x, y, width, height)

pdf.Form.Add(imageForm)

pdf.SaveAs("addImageForm.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Output PDF file: View Image Form PDF. Browsers do not support image forms; please open in Adobe Acrobat to try the feature out.

Image Form

Unsigned Signature Forms via Code

To insert an unsigned or empty signature field, start by creating a signature object. Then, access the Form property of the target PDF and use the Add method to insert the signature object. Lastly, export the PDF with the empty signature field.

:path=/static-assets/pdf/content-code-examples/how-to/signing-unsigned-signature.cs
using IronPdf;
using IronSoftware.Forms;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");

// Configure required parameters
string name = "cert";
uint pageIndex = 0;
double x = 100;
double y = 600;
double width = 300;
double height = 100;

// Create signature
SignatureFormField signature = new SignatureFormField(name, pageIndex, x, y, width, height);

// Add signature
pdf.Form.Add(signature);

pdf.SaveAs("signature.pdf");
Imports IronPdf
Imports IronSoftware.Forms

Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")

' Configure required parameters
Private name As String = "cert"
Private pageIndex As UInteger = 0
Private x As Double = 100
Private y As Double = 600
Private width As Double = 300
Private height As Double = 100

' Create signature
Private signature As New SignatureFormField(name, pageIndex, x, y, width, height)

' Add signature
pdf.Form.Add(signature)

pdf.SaveAs("signature.pdf")
$vbLabelText   $csharpLabel

Output PDF Document

Output PDF file: signature.pdf. Browsers do not support signature forms; please open in Adobe Acrobat to try the feature out.

Image Form

Learn how to fill and edit PDF forms programmatically in the following article: "How to Fill and Edit PDF Forms".

Ready to see what else you can do? Check out our tutorial page here: Sign and Secure PDFs

Preguntas Frecuentes

¿Qué elementos de formulario se pueden agregar a los formularios PDF usando C#?

IronPDF te permite agregar una amplia variedad de elementos de formulario, incluidos campos de texto, áreas de texto, casillas de verificación, cuadros combinados, botones de radio y campos de imágenes a formularios PDF usando C#.

¿Cómo puedo convertir elementos de formulario HTML en un PDF?

Puedes convertir elementos de formulario HTML en un PDF utilizando el método HtmlToPdf.GeneratePdf de IronPDF, que transforma las estructuras de formulario HTML en formularios PDF interactivos.

¿Puedo añadir campos de formulario a un PDF después de que haya sido creado?

Sí, puedes añadir campos de formulario a un PDF existente utilizando la API de IronPDF, que te permite insertar elementos como campos de texto, casillas de verificación y botones de opción de forma programática.

¿Qué pasos son necesarios para añadir un campo de entrada de texto a un PDF usando C#?

Para añadir un campo de entrada de texto a un PDF usando C#, crea un objeto TextFormField y utiliza el método Add en la propiedad Form del documento PDF.

¿Cómo puedo incluir casillas de verificación en mi formulario PDF usando C#?

Las casillas de verificación pueden incluirse en tu formulario PDF ya sea convirtiendo HTML que contiene elementos de casillas de verificación o de forma programática creando un objeto CheckboxFormField en C#.

¿Es posible usar menús desplegables en formularios PDF?

Sí, los menús desplegables pueden implementarse en formularios PDF convirtiendo HTML con etiquetas select o usando un objeto ComboboxFormField en C#.

¿Qué método debería usar para añadir botones de radio a un formulario PDF?

Los botones de radio se pueden añadir a un formulario PDF a través de la conversión de HTML con entradas de radio o de forma programática usando un objeto RadioFormField en IronPDF.

¿Cómo añado un campo de imagen a un formulario PDF?

Puedes añadir un campo de imagen a un formulario PDF creando un ImageFormField en IronPDF y agregándolo al documento de forma programática.

¿Cuál es la mejor manera de insertar un campo de firma sin firmar en un PDF?

Para insertar un campo de firma sin firmar, crea un objeto SignatureFormField y utiliza el método Add para integrarlo en el documento PDF.

¿Cómo puedo saber más sobre la creación y edición de formularios PDF con IronPDF?

Para obtener más información sobre la creación y edición de formularios PDF, puedes consultar la guía 'Cómo Rellenar y Editar Formularios PDF' disponible en el sitio web de IronPDF.

¿IronPDF es compatible con .NET 10 para crear formularios PDF interactivos?

Sí, IronPDF es totalmente compatible con .NET 10. Admite todas las funciones de creación de formularios y renderizado HTML (entradas, casillas de verificación, botones de opción, cuadros combinados, campos de imagen, etc.) en proyectos .NET 10 de forma predeterminada. No se requieren soluciones alternativas especiales. {@see IronPDF es compatible con .NET 10 entre sus plataformas.}

Chaknith Bin
Ingeniero de Software
Chaknith trabaja en IronXL e IronBarcode. Tiene un profundo conocimiento en C# y .NET, ayudando a mejorar el software y apoyar a los clientes. Sus conocimientos derivados de las interacciones con los usuarios contribuyen a mejores productos, documentación y experiencia en general.
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado