4
我在寻找一个简单的API例如,读取PDF文件/模板作为输入,并通过在PDF表单中定义的字段迭代(我认为这是所谓的AcroForm)使用Java和IText,如何从PDF中提取AcroForm字段名称?
我在寻找一个简单的API例如,读取PDF文件/模板作为输入,并通过在PDF表单中定义的字段迭代(我认为这是所谓的AcroForm)使用Java和IText,如何从PDF中提取AcroForm字段名称?
好吧,我已经找到解决方案
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();
}
}