Create TextBox Field
Contents
[
Hide
]
Use FormEditorExamples.createTextBoxField(...) to add text fields to a PDF form.
Create text box fields
- Bind the source PDF to the
FormEditorfacade. - Add each text field with
FieldType.Text, the field name, default value, page number, and rectangle. - 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();
}
}