Reading Form Values

Read field names and their current values from an existing PDF with the Form facade. The example below iterates through the fields and prints each name-value pair.

Get Field Values

Use FormExamples.inspectFormFields(...) to inspect field names and their current values.

public static void inspectFormFields(Path inputFile) {
    Form form = new Form();
    try {
        form.bindPdf(inputFile.toString());
        System.out.println("Field names: " + Arrays.toString(form.getFieldNames()));
        for (String fieldName : form.getFieldNames()) {
            System.out.println(fieldName + " = " + form.getField(fieldName));
        }
    } finally {
        form.close();
    }
}