我正在寻找一个简单的API示例,它将PDF文件/模板作为输入读取,并迭代PDF表单中定义的字段(我认为它被称为AcroForm)
答案 0 :(得分:8)
好的,我找到了解决方案
public static void scanFields(String path) throws IOException {
PdfReader pdfReader = new PdfReader(path);
AcroFields acroFields = pdfReader.getAcroFields();
HashMap<String,AcroFields.Item> fields = acroFields.getFields();
Set<Entry<String, Item>> entrySet = fields.entrySet();
for (Entry<String, Item> entry : entrySet) {
String key = entry.getKey();
}
}