How to Create PDF Forms in Java

IronPDF for Java lets developers build dynamic, interactive PDF forms — text inputs, checkboxes, comboboxes, and radio buttons — by converting HTML into PDFs. The HTML-first approach gives you full control over form layout and behavior using standard web technologies, without learning a proprietary form API. You can also fill existing PDF forms programmatically once you understand how IronPDF models form fields.

Traditional Java PDF libraries require you to construct form fields through low-level PDF objects. IronPDF takes a different path: write your form in HTML and CSS, then render it to a PDF that preserves every interactive field. The result is compatible with Adobe Acrobat Reader and all major PDF viewers.

Quickstart: Create a PDF Form in Java

  1. Add IronPDF for Java to your project via Maven Central
  2. Set your license key with License.setLicenseKey()
  3. Write an HTML string containing standard form elements (<input>, <textarea>, <select>)
  4. Call PdfDocument.renderHtmlAsPdf() to convert the HTML to a PDF
  5. Save the resulting document with saveAs()
//:path=/static-assets/ironpdf-java/howto/create-forms/quickstart-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set license key before any rendering call
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML form with a text field and submit button
String formHtml = "<h2>Registration Form</h2>" +
                  "<form>" +
                  "<label>Name: <input type='text' name='fullname' placeholder='Enter name'></label><br>" +
                  "<button type='submit'>Submit</button>" +
                  "</form>";

// Render HTML to PDF — form fields are preserved
PdfDocument pdf = PdfDocument.renderHtmlAsPdf(formHtml);
pdf.saveAs("registration-form.pdf");
//:path=/static-assets/ironpdf-java/howto/create-forms/quickstart-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set license key before any rendering call
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML form with a text field and submit button
String formHtml = "<h2>Registration Form</h2>" +
                  "<form>" +
                  "<label>Name: <input type='text' name='fullname' placeholder='Enter name'></label><br>" +
                  "<button type='submit'>Submit</button>" +
                  "</form>";

// Render HTML to PDF — form fields are preserved
PdfDocument pdf = PdfDocument.renderHtmlAsPdf(formHtml);
pdf.saveAs("registration-form.pdf");
JAVA

How Do I Create Forms in Java?

IronPDF creates PDF forms from HTML by treating the W3C HTML form specification as the source of truth. Every standard form element — <input>, <textarea>, <select>, <checkbox>, and <radio> — is preserved in the output PDF as an interactive field. You can style these elements with CSS and include custom fonts to match your branding requirements.

When creating forms, IronPDF preserves the interactive nature of HTML form elements in the resulting PDF. Users can fill out forms directly in their PDF viewer without additional software. The forms work with Adobe Acrobat Reader and all commonly deployed PDF viewers, making them accessible across corporate and consumer environments. For advanced rendering options, see the PDF generation settings documentation.

TipsIronPDF does not require a running browser or an installed PDF print driver. The rendering engine is bundled with the library, so forms render identically across development machines, CI servers, and cloud deployments.

How Do I Create Text Input and TextArea Forms?

Text inputs and textareas are the most common PDF form elements — useful for collecting names, email addresses, comments, and multi-line descriptions. IronPDF maps <input type="text"> to single-line PDF text fields and <textarea> to multi-line fields that retain their row and column dimensions.

The HTML form elements maintain their functionality when converted to PDF. Users can click into fields, type text, and move between inputs using the Tab key, the same as any web form. Default values, placeholder text, and HTML5 validation attributes such as required and pattern are respected during conversion. For fine-grained layout control, combine form elements with custom paper sizes and margin settings.

//:path=/static-assets/ironpdf-java/howto/create-forms/text-input-textarea-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with single-line inputs and a multi-line textarea
String htmlContent = """
<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>
""";

// Render HTML — both <input> and <textarea> become interactive PDF fields
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("textAreaAndInputForm.pdf");
//:path=/static-assets/ironpdf-java/howto/create-forms/text-input-textarea-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with single-line inputs and a multi-line textarea
String htmlContent = """
<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>
""";

// Render HTML — both <input> and <textarea> become interactive PDF fields
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("textAreaAndInputForm.pdf");
JAVA

The renderHtmlAsPdf call on the PdfDocument class converts the HTML into a fully interactive PDF. Each named form field becomes a distinct field in the PDF's AcroForm dictionary, readable by any standards-compliant PDF viewer. The field names you set in the name attribute (firstname, lastname, address) are preserved in the output and can be read back when you extract form data later.

Output PDF Document:


How Do I Create Checkbox and Combobox Forms?

Checkboxes and comboboxes cover the two most common selection patterns in PDF forms: binary on/off choices and single-item selection from a list. IronPDF maps <input type="checkbox"> to PDF checkbox fields and <select> elements to PDF combobox (dropdown) fields.

Combobox fields allow users to pick from a fixed list of options defined by <option> elements. You can pre-select a default by adding the selected attribute to an option, group related choices with <optgroup>, and use CSS to match the dropdown's appearance to your document design. The name attribute on the <select> element becomes the field name in the resulting PDF, making form data extraction straightforward. See the Apache PDFBox project for details on how PDF AcroForm fields store this selection data if you need to process forms with other tools.

//:path=/static-assets/ironpdf-java/howto/create-forms/checkbox-combobox-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with a checkbox and a select dropdown
String htmlContent = """
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <h3>Task Completed</h3>
        <label>
            <input type='checkbox' id='taskCompleted' name='taskCompleted'> Mark task as completed
        </label>
        <h3>Select Priority</h3>
        <label for='priority'>Choose priority level:</label>
        <select id='priority' name='priority'>
            <option value='high'>High</option>
            <option value='medium' selected>Medium</option>
            <option value='low'>Low</option>
        </select>
    </body>
</html>
""";

// Render HTML — checkbox and combobox fields are preserved in the PDF
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("checkboxAndComboboxForm.pdf");
//:path=/static-assets/ironpdf-java/howto/create-forms/checkbox-combobox-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with a checkbox and a select dropdown
String htmlContent = """
<html>
    <body>
        <h2>Editable PDF Form</h2>
        <h3>Task Completed</h3>
        <label>
            <input type='checkbox' id='taskCompleted' name='taskCompleted'> Mark task as completed
        </label>
        <h3>Select Priority</h3>
        <label for='priority'>Choose priority level:</label>
        <select id='priority' name='priority'>
            <option value='high'>High</option>
            <option value='medium' selected>Medium</option>
            <option value='low'>Low</option>
        </select>
    </body>
</html>
""";

// Render HTML — checkbox and combobox fields are preserved in the PDF
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("checkboxAndComboboxForm.pdf");
JAVA

The checkbox field stores a boolean state (/On or /Off in PDF notation) that downstream code can read when processing submitted forms. The combobox stores the value attribute of the selected <option>. Both field types remain interactive in the saved PDF — users can check the box or change the dropdown selection without any additional plugins or JavaScript.

Output PDF Document:


How Do I Create Radio Button Forms?

Radio buttons present a mutually exclusive choice: once a user selects one option in a group, any previously selected option in the same group is automatically deselected. IronPDF maps <input type="radio"> elements that share a name attribute to a single grouped radio field in the PDF's AcroForm dictionary.

All radio buttons in a group must share the same name attribute value — this is what links them in the PDF. Each button's value attribute determines what the field stores when that option is selected. If no button in the group is selected, the field value is None. You can read the current selection back using the getForm() and getFields() methods on a loaded PdfDocument, which lets you build workflows that pre-fill forms or validate submitted data. For a worked example of reading form fields, see the PDF form data example.

//:path=/static-assets/ironpdf-java/howto/create-forms/radio-button-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with a radio button group — all three share name='traveltype'
String htmlContent = """
<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>
""";

// Render HTML — all three radio inputs become one grouped field in the PDF
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("radioButtonForm.pdf");
//:path=/static-assets/ironpdf-java/howto/create-forms/radio-button-form.java
import com.ironsoftware.ironpdf.License;
import com.ironsoftware.ironpdf.PdfDocument;

// Set the license key for IronPDF
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");

// HTML with a radio button group — all three share name='traveltype'
String htmlContent = """
<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>
""";

// Render HTML — all three radio inputs become one grouped field in the PDF
PdfDocument pdfDoc = PdfDocument.renderHtmlAsPdf(htmlContent);

// Save the document
pdfDoc.saveAs("radioButtonForm.pdf");
JAVA

Because the three <input type="radio"> elements share the name="traveltype" attribute, IronPDF creates a single AcroForm radio group in the output PDF. Selecting "Car" in Acrobat Reader, for example, sets the field value to Car and clears any prior selection. This behavior mirrors what users expect from radio button groups in web forms, making the transition from web to PDF data collection natural.

Please noteRadio button group names must be unique across the entire form. Reusing the same name across different logical groups merges them into a single field, preventing independent selection.

How Do I Apply Best Practices for PDF Form Creation?

Reliable PDF forms require attention to both rendering configuration and long-term maintainability. The most common issue is a form that looks correct in the browser but loses interactivity after conversion — typically caused by missing name attributes on form elements. Always assign a name to every field; IronPDF uses this value as the PDF field identifier, and fields without names may be dropped or merged.

Test forms in multiple PDF viewers before distribution. Adobe Acrobat Reader is the reference implementation, but many enterprise environments deploy Foxit Reader or browser-based viewers, all of which handle edge cases slightly differently. Use the HTML5 validation attributes (required, minlength, pattern) that IronPDF respects during rendering to catch data quality issues at form-fill time rather than in your backend. For sensitive documents, apply passwords and security settings to protect the form from unauthorized editing.

When deploying to production, set your license key before the first rendering call and keep it in a secure configuration store rather than hard-coding it. IronPDF publishes deployment guides for AWS, Azure, and Google Cloud environments. Review the license keys guide for details on trial and production key behavior.

TipsKeep form field names short and alphanumeric. Some PDF readers truncate or reject field names containing spaces or special characters, which can break form data extraction.

What Are the Next Steps for Creating PDF Forms in Java?

This guide covered the four primary interactive form field types — text inputs, textareas, checkboxes, comboboxes, and radio buttons — and demonstrated how IronPDF converts standard HTML form markup into fully interactive PDFs. Each field type maps directly to its HTML counterpart, so existing web form templates can be reused with minimal modification.

From here, consider exploring:

  • Read and process form data: Use getForm() and getFields() to extract submitted values from a filled PDF. The form data example shows the full read-back workflow.
  • Pre-fill forms programmatically: Combine form creation with the fill PDF forms guide to generate pre-populated documents for each recipient.
  • Secure your forms: Add password protection and restrict editing with the security and metadata settings example.
  • Advanced rendering: Control paper size, margins, headers, and footers via the PDF generation settings guide.

Start your free trial to test form creation without a paid license. When your project is ready for production, view licensing options for the plan that fits your deployment.

Ready to see what else IronPDF can do? Check out the full HTML to PDF tutorial here: HTML to PDF conversion in Java

Frequently Asked Questions

What is the easiest way to create PDF forms in Java?

IronPDF for Java creates PDF forms from standard HTML. Write an HTML string with <input>, <textarea>, or <select> elements, pass it to PdfDocument.renderHtmlAsPdf(), and save the result. Every named field becomes an interactive AcroForm field in the output PDF.

What types of form fields does IronPDF support in Java?

IronPDF maps all standard HTML form elements to their PDF equivalents: <input type='text'> becomes a single-line text field, <textarea> becomes a multi-line text field, <input type='checkbox'> becomes a checkbox field, <select> becomes a combobox, and <input type='radio'> grouped by the same name attribute becomes a radio button group.

Do I need Adobe Acrobat to create fillable PDFs in Java?

No. IronPDF bundles its own rendering engine, so no desktop PDF application is required. The fillable PDFs it produces are compatible with Adobe Acrobat Reader, Foxit Reader, and all major PDF viewers.

Can I style PDF forms with CSS in Java?

Yes. Because IronPDF renders HTML to PDF, you can apply CSS to control field size, font, color, and layout. Custom web fonts loaded via a <link> tag in your HTML are also embedded in the output PDF.

How do radio button groups work in IronPDF for Java?

All <input type='radio'> elements sharing the same name attribute are grouped into a single AcroForm radio field. Selecting one option deselects the others. If no option is selected, the field value is None. Read the value back using getForm().getFields() on a loaded PdfDocument.

Can I read back data from forms created with IronPDF?

Yes. Load the filled PDF with PdfDocument.fromFile(), then call getForm().getFields() to iterate over all AcroForm fields and read their current values. The field names correspond to the name attributes you set in your original HTML.

Darrius Serrant
Full Stack Software Engineer (WebOps)

Darrius Serrant holds a Bachelor’s degree in Computer Science from the University of Miami and works as a Full Stack WebOps Marketing Engineer at Iron Software. Drawn to coding from a young age, he saw computing as both mysterious and accessible, making it the perfect medium for creativity ...

Read More
Ready to Get Started?
Version: 2026.4 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.