finding out required fields to fill in pdf file

后端 未结 2 1735
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 12:19

I\'m starting with new functionality in my android application which will help to fill certain PDF forms.

I find out that the best solution will be to use iText library.

2条回答
  •  情书的邮戳
    2021-01-21 13:05

    Please take a look at section 13.3.4 of my book, entitled "AcroForms revisited". Listing 13.15 shows a code snippet from the InspectForm example that checks whether or not a field is a password or a multi-line field.

    With some minor changes, you can adapt that example to check for required fields:

    for (Map.Entry entry : fields.entrySet()) {
        out.write(entry.getKey());
        item = entry.getValue();
        dict = item.getMerged(0);
        flags = dict.getAsNumber(PdfName.FF);
        if (flags != null && (flags.intValue() & BaseField.REQUIRED) > 0)
            out.write(" -> required\n");
    }
    

提交回复
热议问题