PDF Forms
IronPDF for Python can both create interactive PDF forms from HTML and read or write the field values of existing PDF forms programmatically.
Getting Started
Enable form creation by setting RenderingOptions.CreatePdfFormsFromHtml = True before rendering HTML that contains <input>, <select>, or <textarea> elements. To read or write field values in an existing form, load the PDF and use Form.FindFormField.
Understanding the Code
Creating Forms
CreatePdfFormsFromHtml = True: Converts HTML form elements (<input>,<radio>,<checkbox>, etc.) into interactive PDF form fields when rendering.RenderHtmlAsPdf(form_html): Renders the HTML form as a PDF with interactive, fillable fields.SaveAs("BasicForm.pdf")writes it to disk.
Reading and Writing Field Values
PdfDocument.FromFile("BasicForm.pdf"): Loads the saved form PDF for field manipulation.form_document.Form.FindFormField(name): Returns a form field object for the field with the givennameattribute value from the original HTML.field.Value = "text": Sets the value of the form field programmatically.field.Value: Reads the current value of the form field.SaveAs("FilledForm.pdf"): Saves the PDF with all field values populated.
Supported Form Field Types
IronPDF supports text inputs, radio buttons, checkboxes, dropdowns (<select>), and text areas. All are created automatically from the corresponding HTML elements when CreatePdfFormsFromHtml is enabled.






