这将向您显示该字段出现在什么页面上(从0开始):
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);}


