Create ListBox Field

Use FormEditorExamples.createListBoxField(...) to create a list box with predefined items.

Create a list box field

  1. Bind the source PDF to the FormEditor facade.
  2. Define the available list items with setItems(...).
  3. Add the list box field with its default value and rectangle.
  4. Save the updated document.
public static void createListBoxField(Path inputFile, Path outputFile) {
    FormEditor editor = new FormEditor();
    try {
        editor.bindPdf(inputFile.toString());
        editor.setItems(new String[] {"Australia", "New Zealand", "Malaysia"});
        editor.addField(FieldType.ListBox, "listbox1", "Australia", 1, 230, 398, 350, 514);
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}