public static List<PDFAreaModel> getSignature(String pdfFile) throws IOException {
PDDocument document = PDDocument.load(new File(pdfFile));
List<PDFAreaModel> signModelList = new ArrayList<PDFAreaModel>();
List<PDSignatureField> fields = document.getSignatureFields();
for(PDSignatureField f:fields){
PDAnnotationWidget widget = f.getWidgets().get(0);
String name = f.getFullyQualifiedName();
PDPage pdPage = widget.getPage();
int page = 0;
for(int i = 0;i < document.getNumberOfPages();i++){
PDPage p = document.getPage(i);
if(p.equals(pdPage)){
page = i;
break;
}
}
PDRectangle pdRectangle = widget.getRectangle();
signModelList.add(new PDFAreaModel(name, page,(int)pdRectangle.getLowerLeftX(), (int)pdRectangle.getLowerLeftY(), (int)pdRectangle.getWidth(),(int)pdRectangle.getHeight(), f.getSignature()!=null));
}
return signModelList;
}
转载于:https://my.oschina.net/zdglf/blog/912131