Create TextBox Field

Use FormEditorExamples.createTextBoxField(...) to add text fields to a PDF form.

Create text box fields

  1. Bind the source PDF to the FormEditor facade.
  2. Add each text field with FieldType.Text, the field name, default value, page number, and rectangle.
  3. Save the updated document.
public static void createTextBoxField(Path inputFile, Path outputFile) {
    FormEditor editor = new FormEditor();
    try {
        editor.bindPdf(inputFile.toString());
        editor.addField(FieldType.Text, "first_name", "Alexander", 1, 50, 570, 150, 590);
        editor.addField(FieldType.Text, "last_name", "Smith", 1, 235, 570, 330, 590);
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}