How to Fill and Edit PDF Forms
IronPDF offers an intuitive toolset to edit existing forms in a PDF document, including text areas, text inputs, checkboxes, combo boxes, and radio buttons.
Get started with IronPDF
Start using IronPDF in your project today with a free trial.
How to Fill and Edit PDF Forms
- Download a C# library for filling and editing PDF forms
- Import the targeted PDF document using the
FromFile
method - Find the form object to modify using the
FindFormField
method - Modify the Value property to set the desired information
- Export the edited PDF document
Edit Forms
IronPDF effortlessly edits existing form fields of various types in a PDF document.
Text Area and Input Forms
To edit text areas and input forms, assign the Value property to the desired information. The code below first finds the form object using the FindFormField
method with the form name. Then, it accesses and assigns the Value property of the object.
:path=/static-assets/pdf/content-code-examples/how-to/edit-forms-input-textarea.cs
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("textAreaAndInputForm.pdf");
// Set text input form values
pdf.Form.FindFormField("firstname").Value = "John";
pdf.Form.FindFormField("lastname").Value = "Smith";
// Set text area form values
pdf.Form.FindFormField("address").Value = "Iron Software LLC\r\n205 N. Michigan Ave.";
pdf.SaveAs("textAreaAndInputFormEdited.pdf");
Imports Microsoft.VisualBasic
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("textAreaAndInputForm.pdf")
' Set text input form values
pdf.Form.FindFormField("firstname").Value = "John"
pdf.Form.FindFormField("lastname").Value = "Smith"
' Set text area form values
pdf.Form.FindFormField("address").Value = "Iron Software LLC" & vbCrLf & "205 N. Michigan Ave."
pdf.SaveAs("textAreaAndInputFormEdited.pdf")
Output PDF document
Checkbox and Combobox Forms
Edit existing checkbox and combobox forms by first finding the form field by its name. Assign the Value property to 'Yes' to check the checkbox form. Select any available choice in the combobox by assigning the desired choice to its Value property. For convenience, retrieve all the choices' values by accessing the Choices property.
:path=/static-assets/pdf/content-code-examples/how-to/edit-forms-checkbox-combobox.cs
using IronPdf;
using System;
// Load a PDF document from a file
PdfDocument pdf = PdfDocument.FromFile("checkboxAndComboboxForm.pdf");
// Find the checkbox form field within the PDF and check it (set its value to "Yes")
var checkboxForm = pdf.Form.FindFormField("taskCompleted");
if (checkboxForm != null)
{
checkboxForm.Value = "Yes";
}
else
{
Console.WriteLine("Checkbox form field 'taskCompleted' not found.");
}
// Find the combobox form field within the PDF and set its value to "Low"
var comboboxForm = pdf.Form.FindFormField("priority");
if (comboboxForm != null)
{
comboboxForm.Value = "Low";
// Print out all the available choices for the combobox to the console
foreach (var choice in comboboxForm.Choices)
{
Console.WriteLine(choice);
}
}
else
{
Console.WriteLine("Combobox form field 'priority' not found.");
}
// Save the modified PDF with the new form field values to a new file
pdf.SaveAs("checkboxAndComboboxFormEdited.pdf");
Imports IronPdf
Imports System
' Load a PDF document from a file
Private pdf As PdfDocument = PdfDocument.FromFile("checkboxAndComboboxForm.pdf")
' Find the checkbox form field within the PDF and check it (set its value to "Yes")
Private checkboxForm = pdf.Form.FindFormField("taskCompleted")
If checkboxForm IsNot Nothing Then
checkboxForm.Value = "Yes"
Else
Console.WriteLine("Checkbox form field 'taskCompleted' not found.")
End If
' Find the combobox form field within the PDF and set its value to "Low"
Dim comboboxForm = pdf.Form.FindFormField("priority")
If comboboxForm IsNot Nothing Then
comboboxForm.Value = "Low"
' Print out all the available choices for the combobox to the console
For Each choice In comboboxForm.Choices
Console.WriteLine(choice)
Next choice
Else
Console.WriteLine("Combobox form field 'priority' not found.")
End If
' Save the modified PDF with the new form field values to a new file
pdf.SaveAs("checkboxAndComboboxFormEdited.pdf")
Output PDF document
Radio buttons Forms
When working with radio button forms in IronPDF, radio buttons of the same group are contained within one form object. To edit the radio button value, simply assign the Value property of the form object to one of the available choices. Retrieve all the available choices with the Annotations property. The code below demonstrates how to edit the radio button value.
:path=/static-assets/pdf/content-code-examples/how-to/edit-forms-radiobutton.cs
using IronPdf;
using System;
// Load the PDF document from the local file system
PdfDocument pdf = PdfDocument.FromFile("radioButtonForm.pdf");
// Find the form field associated with radio buttons
var radioForm = pdf.Form.FindFormField("traveltype");
if (radioForm != null)
{
// Set the radio button value to the desired option
radioForm.Value = "Airplane";
// Print out all the available choices for this radio button field
// Annotations are often used for different options in radio buttons
foreach (var annotation in radioForm.Annotations)
{
// Display the on-appearance state of each radio button choice
Console.WriteLine(annotation.OnAppearance);
}
// Save the modified PDF document under a new file name
pdf.SaveAs("radioButtonFormEdited.pdf");
}
else
{
Console.WriteLine("Radio form field 'traveltype' was not found.");
}
Imports IronPdf
Imports System
' Load the PDF document from the local file system
Private pdf As PdfDocument = PdfDocument.FromFile("radioButtonForm.pdf")
' Find the form field associated with radio buttons
Private radioForm = pdf.Form.FindFormField("traveltype")
If radioForm IsNot Nothing Then
' Set the radio button value to the desired option
radioForm.Value = "Airplane"
' Print out all the available choices for this radio button field
' Annotations are often used for different options in radio buttons
For Each annotation In radioForm.Annotations
' Display the on-appearance state of each radio button choice
Console.WriteLine(annotation.OnAppearance)
Next annotation
' Save the modified PDF document under a new file name
pdf.SaveAs("radioButtonFormEdited.pdf")
Else
Console.WriteLine("Radio form field 'traveltype' was not found.")
End If
Additionally, use the Clear
method to deselect the radio button. This method can only be accessed when the object is of type RadioFormField. Upon accessing the radio form object from the PDF, it can be cast to the RadioFormField type.
Output PDF document
Remove Forms
To remove forms from the PDF, first select the target form using the FindFormField
method. Pass the form object to the Form.Remove
method, which can be accessed from the PdfDocument object.
:path=/static-assets/pdf/content-code-examples/how-to/edit-forms-remove-form.cs
using IronPdf; // Import the IronPdf library for handling PDF documents.
using IronSoftware.Forms; // Import the IronSoftware.Forms library to handle form fields.
// Load an existing PDF document from a file named "textAreaAndInputForm.pdf".
PdfDocument pdf = PdfDocument.FromFile("textAreaAndInputForm.pdf");
// Find the form field with the name "firstname" in the PDF.
// The method FindFormField is used to get a handle on the form field if it exists.
IFormField targetForm = pdf.Form.FindFormField("firstname");
// Check if the form field was found before attempting to remove it.
// This prevents potential errors if the form field does not exist.
if (targetForm != null)
{
// Remove the identified form field from the PDF.
// Once removed, this field will no longer appear in the document.
pdf.Form.Remove(targetForm);
}
// Save the modified PDF to a new file called "removedForm.pdf".
// This ensures that the original document is not altered and a new version is saved.
pdf.SaveAs("removedForm.pdf");
// The above code demonstrates how to load a PDF, locate and remove a specific form field,
// and then save the modified PDF to a new file.
// Ensure that the IronPdf and IronSoftware.Forms libraries are properly referenced in your project.
Imports IronPdf ' Import the IronPdf library for handling PDF documents.
Imports IronSoftware.Forms ' Import the IronSoftware.Forms library to handle form fields.
' Load an existing PDF document from a file named "textAreaAndInputForm.pdf".
Private pdf As PdfDocument = PdfDocument.FromFile("textAreaAndInputForm.pdf")
' Find the form field with the name "firstname" in the PDF.
' The method FindFormField is used to get a handle on the form field if it exists.
Private targetForm As IFormField = pdf.Form.FindFormField("firstname")
' Check if the form field was found before attempting to remove it.
' This prevents potential errors if the form field does not exist.
If targetForm IsNot Nothing Then
' Remove the identified form field from the PDF.
' Once removed, this field will no longer appear in the document.
pdf.Form.Remove(targetForm)
End If
' Save the modified PDF to a new file called "removedForm.pdf".
' This ensures that the original document is not altered and a new version is saved.
pdf.SaveAs("removedForm.pdf")
' The above code demonstrates how to load a PDF, locate and remove a specific form field,
' and then save the modified PDF to a new file.
' Ensure that the IronPdf and IronSoftware.Forms libraries are properly referenced in your project.
Output PDF document
Learn how to create PDF forms programmatically in the following article: "How to Create PDF Forms."
Frequently Asked Questions
How can I start editing PDF forms using a C# library?
To start editing PDF forms using IronPDF, first download the C# library from NuGet. Then, import the PDF document using the FromFile method, locate the form field using FindFormField, and modify the Value property as needed.
How do I edit text areas and input forms in a PDF using a C# library?
To edit text areas and input forms, use the FindFormField method to locate the form field by name. Then, assign the desired value to the Value property of the form field object in IronPDF.
How can I edit checkboxes and comboboxes in a PDF form with a C# library?
To edit checkboxes, set the Value property to 'Yes'. For comboboxes, assign the desired choice to the Value property after finding the field with FindFormField. You can access all choice values using the Choices property in IronPDF.
What is the method to edit radio button forms using a C# library?
Radio buttons are edited by assigning the desired choice to the Value property of the form object in IronPDF. Access all available choices using the Annotations property, and use the Clear method to deselect a radio button.
How can I remove forms from a PDF using a C# library?
To remove a form from a PDF, use the FindFormField method to select the form field, then pass the field object to the Form.Remove method from the PdfDocument object in IronPDF.
Can a C# library be used to edit existing PDF form fields of any type?
Yes, IronPDF can edit existing form fields such as text areas, text inputs, checkboxes, comboboxes, and radio buttons in a PDF document.
Is it possible to programmatically create PDF forms using a C# library?
Yes, you can programmatically create PDF forms using IronPDF. For more information, refer to the article '[How to Create PDF Forms](/how-to/create-forms/)'.
What additional features does a document management solution provide?
IronSecureDoc offers solutions for managing SaaS services like digital signing, redaction, encryption, and protection, all with a one-time payment.