Reputation: 253
I want to know how to retrieve the coordinates of signature form fields in a PDF using PDFBOX or OpenPDF. The input PDF contains an electronic signature which is digitally signed.
Looking forward for your Help.
Upvotes: 0
Views: 1051
Reputation: 9816
Placeholder means unsigned signature for me but you mentioned signed fields. But I write you both solutions for openPDF:
PdfReader reader = new PdfReader(...)
AcroFields fields = reader.getAcroFields();
//unsigned signatures
//ArrayList<String> al = fields.getBlankSignatureNames();
//signed signatures
ArrayList<String> al = fields.getSignatureNames();
for (int i = 0; i < al.size(); i++) {
String fieldName = al.get(i);
float[] position = fields.getFieldPositions(fieldName);
//assuming that signatures doesn't have several widgets. (like it can be for other fields)
for(int i=0;i<position.length;i+=5){
int pageNumber = (int) position[0];
float lowerLeftX = position[1];
float lowerLeftY = position[2];
float upperRightX = position[3];
float upperRightY = position[4];
System.out.println("llx:"+lowerLeftX+" lly:"+lowerLeftY+" urx:"+upperRightX+" ury: "upperRightY);
}
Upvotes: 1