i\'m trying to get the field page in my project, and i dont know how to get the page number for each field and field. i have this code:
String formTempla
This will show you on what page(s) (0-based) the field appears:
PDField field = acroForm.getField( "date" );
for (PDAnnotationWidget widget : field.getWidgets())
{
PDPage page = widget.getPage();
if (page == null)
{
// incorrect PDF. Plan B: try all pages to check the annotations.
for (int p = 0; p < doc.getNumberOfPages(); ++p)
{
List<PDAnnotation> annotations = doc.getPage(p).getAnnotations();
for (PDAnnotation ann : annotations)
{
if (ann.getCOSObject() == widget.getCOSObject())
{
System.out.println("found at page: " + p);
break;
}
}
}
continue;
}
int pageNum = pdfDocument.getPages().indexOf(page);
System.out.println("found at page: " + pageNum);
}