创建 ComboBox 字段

使用 FormEditorExamples.createComboBoxField(...) 创建组合框并添加可选择的项。

创建 combo box 字段

  1. 将源 PDF 绑定到 FormEditor 对象。
  2. 添加组合框字段及其默认值和目标矩形。
  3. 添加可选择的组合框项目。
  4. 保存更新后的文档。
public static void createComboBoxField(Path inputFile, Path outputFile) {
    FormEditor editor = new FormEditor();
    try {
        editor.bindPdf(inputFile.toString());
        editor.addField(FieldType.ComboBox, "combobox1", "Australia", 1, 230, 498, 350, 514);
        editor.addListItem("combobox1", new String[] {"Australia", "Australia"});
        editor.addListItem("combobox1", new String[] {"New Zealand", "New Zealand"});
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}