0

我想知道如何使用 PDFBOX 或 OpenPDF 检索 PDF 中签名表单字段的坐标。输入 PDF 包含经过数字签名的电子签名。

期待您的帮助。

4

1 回答 1

1

占位符对我来说意味着未签名的签名,但您提到了签名字段。但我为你写了两个 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);
 }
于 2019-02-15T12:00:40.753 回答