PDF Forms

You can create editable PDF documents with IronPDF as easily as a normal document. The PdfForm class is a collection of user-editable form fields within a PDF document. It can be implemented into your PDF render to make it a form or an editable document.

This example shows you how to create editable PDF forms in IronPDF.

PDFs with editable forms can be created from HTML simply by adding <form>, <input>, and <textarea> tags to the document parts.

The PdfDocument.Form.FindFormField method can be used to read and write the value of any form field. The field's name will be the same as the 'name' attribute given to that field in your HTML.

The PdfDocument.Form object can be used in two ways:

  • Populating Default Values: This can be used to set a default value for form fields that will be displayed in PDF viewers like Adobe Reader.
  • Reading User Input: After the user fills in the form, the form fields can be accessed and the data read back into your application.

In the example above, we first import the IronPdf library and define a method CreateEditablePdfDocument. This method contains the HTML structure of a simple form with input fields for username and comments. Using the HtmlToPdf renderer, we convert this HTML content into a PDF document.

The pdfDocument.Form is then used to access and manipulate the form fields. We set default values that will appear when the document is opened in a PDF viewer. Finally, the document is saved with the name "EditableForm.pdf", allowing it to be stored or shared with embedded editable fields.

Unlock the Full Potential of PDF Forms with Our Editing Guide