创建 ListBox 字段

使用 FormEditorExamples.createListBoxField(...) 创建一个带有预定义项的列表框。

创建 list box 字段

  1. 将源 PDF 绑定到 FormEditor 对象。
  2. 使用以下方式定义可用的列表项 setItems(...)。
  3. 添加带有默认值和矩形的列表框字段。
  4. 保存更新后的文档。
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();
    }
}