Hello, there is a sample PDF with field “FIELD2” appearing 3 times in document. How we can get all field’s appearances? We tried Field.size(), but it returns 0. Also, when field created dynamically with Form.add method and then addFieldAppearance called multiple times, Field.size() returns correct value.
Hi John,
Any progress on this?
Hi John,
Hi John,
Thanks for your patience.
We have further investigated earlier reported PDFJAVA-36062 and in order to resolve this problem, please try using following code snippet.
[Java]
Document pdf = new Document(myDir + "input.pdf");
System.out.println(pdf.getPages().get_Item(1).getAnnotations().size());
for (Annotation a : (Iterable) pdf.getPages().get_Item(1).getAnnotations()) {
System.out.println("Annot Name: " + a.getFullName() + " Rect: " + a.getRect());
}
The output will be
4
Annot Name: FIELD1 Rect: 50.25,697.5,162,731.25
Annot Name: FIELD2 Rect: 177,693.75,334.5,733.5
Annot Name: FIELD2 Rect: 177,642.75,334.5,682.5
Annot Name: FIELD2 Rect: 177.75,588.75,335.25,628.5