Nutrient Java SDK

Fill and edit PDF forms in Java

  • Fill text fields, checkboxes, radio buttons, dropdowns, and list boxes programmatically
  • Set field properties — mark as read-only, required, or read default values
  • Batch fill and update fields by iterating the form field collection
  • Navigate hierarchical field structures and access widget annotations for visual customization

Need pricing or implementation help? Talk to Sales.

PDF FORM FILLING IN JAVA

Document document = Document.open("form.pdf");
PdfEditor editor = PdfEditor.edit(document);
PdfFormFieldCollection formFields = editor.getFormFieldCollection();
// Fill a text field.
PdfFormField textField = formFields.findByFullName("Name");
if (textField != null) {
((PdfTextField) textField).setValue("John Doe");
}
// Check a checkbox.
PdfFormField checkbox = formFields.findByFullName("Agree");
if (checkbox != null) {
((PdfCheckBoxField) checkbox).setIsChecked(true);
}
editor.saveAs("filled_form.pdf");

USE CASES

When developers reach for this SDK

Prepopulate forms from database records

Customer data, application details, or policy information lives in a database. The SDK fills PDF forms from that data — text fields, checkboxes, dropdowns — without requiring users to type anything.

Batch fill thousands of forms

Insurance claims, HR onboarding packets, or tax documents often need the same template filled with different data. Iterate the form field collection in a loop and process entire batches from CSV or database records.

Lock fields after approval

Once a form has been reviewed and approved, certain fields need to become immutable. Programmatically set fields to read-only so they remain visible but reject further user input.

Enforce required field validation

Mark critical fields as required so PDF viewers display validation indicators and prevent submission when those fields are empty. Apply the rule across all text fields at once with batch processing.

PDF form capabilities for Java

Fill form fields

Populate text fields with string values and set checkbox states. Look up fields by their fully qualified name and set values with type-specific methods.


  • Fill text fields with string values
  • Set checkbox checked or unchecked states
  • Find fields by fully qualified name

Select options in forms

Choose radio button options, dropdown items, and list box entries. Radio buttons support mutually exclusive selection; list boxes support single or multiple selection.


  • Select radio button options by export value
  • Choose dropdown (combo box) items from option lists
  • Select single or multiple list box entries

Edit field properties

Control field behavior by setting read-only flags, marking fields as required, and reading default values. Navigate parent-child field hierarchies.


  • Set fields to read-only to lock after approval
  • Mark fields as required for validation enforcement
  • Read default values for form reset operations

Batch operations

Iterate the entire form field collection and apply operations conditionally by field type. Fill, validate, or lock fields in bulk using standard Java loops.


  • Iterate all fields and fill by type
  • Filter terminal fields and skip read-only ones
  • Apply validation rules across all fields at once


ADVANCED CAPABILITIES

Beyond basic form filling

The SDK covers the full lifecycle of PDF form fields — fill values, edit properties, enforce validation, lock sections, and navigate hierarchical field structures. All operations work with standard Java patterns and exception handling.

Illustration of PDF form viewing and filling
Field hierarchy navigation

Form fields can have parent-child relationships. Navigate these structures to access nested fields grouped under parent containers like address or contact sections.


Widget annotation access

Terminal fields have associated widget annotations that define their visual appearance and page position. Access these for appearance customization and layout analysis.


Add new form fields

Create text fields, checkboxes, radio button groups, dropdowns, list boxes, push buttons, and signature fields from scratch and add them to any page.


Automatic resource cleanup

Documents opened with try-with-resources are closed automatically. The editor handles all internal state management, so you only manage your business logic.


Frequently asked questions

How do I fill a PDF form in Java?

Open a document, create an editor, and retrieve the form field collection. Look up fields by their fully qualified name, cast to the specific field type, and set the value. Save the document when done. The SDK handles field parsing, type validation, and appearance updates. See the form filling guide for complete Java examples.

How do I select a dropdown or radio button value in a PDF form?

Look up the field by name, verify the field type, and cast to the appropriate type. For radio buttons, select an option by its export value; the SDK automatically deselects the previous option. For combo boxes (dropdowns), select by matching the value to one of the predefined options. See the form filling guide.

How do I make a PDF form field read-only in Java?

Find the field by name and set its read-only flag. The field remains visible in PDF viewers but rejects user input. This is commonly used to lock fields after approval or to display reference data that shouldn’t be edited. See the editing field properties guide.

How do I mark a form field as required?

Find the field and set its required flag. PDF viewers typically display visual indicators (borders, asterisks) for required fields and can prevent submission when they’re empty. You can apply this across all text fields at once using batch iteration. See the editing field properties guide.

Can I batch fill thousands of PDF forms in Java?

Yes. The SDK is a standard Java library, so you can iterate through records in a loop and fill each form from a database, CSV, or any data source. Each form follows the same pattern: open, fill fields, save. The form field collection supports iteration and conditional logic for type-specific handling.

What PDF form field types does the SDK support?

The SDK supports text fields, checkboxes, radio buttons, combo boxes (dropdowns), list boxes, push buttons, and signature fields. You can fill existing fields, edit their properties, and add new fields of any type to a document. See the add form fields guide for creating new fields.

How do I navigate hierarchical form fields?

Form fields can have parent-child relationships — for example, an Address parent with Street, City, and Zip children. Check whether a field is terminal (leaf node with a value) or a parent with children. Parent fields expose a child count and indexed access to each child field. See the editing field properties guide.

Can I add new form fields to an existing PDF?

Yes. The SDK supports creating all standard form field types — text fields (single and multiline), checkboxes, radio button groups, combo boxes, list boxes, push buttons, and signature fields — and adding them to any page. See the add form fields guide.


FREE TRIAL

Ready to get started?

Start filling and editing PDF forms in Java in minutes — no payment information required.