开发者

Using Java and IText, how to extract AcroForm field names from a PDF?

开发者 https://www.devze.com 2023-01-04 13:42 出处:网络
I\'m looking 开发者_开发技巧for a simple API example, that reads a PDF file / template as an input, and iterates over the fields defined in the PDF form (I think it is called AcroForm)Ok, I have found

I'm looking 开发者_开发技巧for a simple API example, that reads a PDF file / template as an input, and iterates over the fields defined in the PDF form (I think it is called AcroForm)


Ok, I have found the solution

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();
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消