/** * This method determines if the given field is a button. * * @param field the field to determine * @return the result of the determination * @throws IOException If there is an error determining the field type. */ private static boolean isButton(PDField field) throws IOException { String ft = field.findFieldType(); boolean retval = FIELD_TYPE_BTN.equals(ft); List kids = field.getKids(); if (ft == null && kids != null && kids.size() > 0) { // sometimes if it is a button the type is only defined by one // of the kids entries Object obj = kids.get(0); COSDictionary kidDict = null; if (obj instanceof PDField) { kidDict = ((PDField) obj).getDictionary(); } else if (obj instanceof PDAnnotationWidget) { kidDict = ((PDAnnotationWidget) obj).getDictionary(); } else { throw new IOException("Error:Unexpected type of kids field:" + obj); } retval = isButton(new PDUnknownField(field.getAcroForm(), kidDict)); } return retval; }