Itext计算签名签名字段的数量

时间:2013-12-02 21:54:50

标签: java itext

我需要获取pdf文档中已签名字段的数量。现在我这样做:

ServletContext app = getServletContext();
String path = app.getRealPath("/CompesationReportsPdfDocuments/mySignedPdf.pdf");
File thePdf = new File(path);
int numberOfSignedFields=0;
PdfReader reader = new PdfReader(path);
AcroFields fields = reader .getAcroFields();
numberOfSignedFields=fields.getSignatureNames().size();
reader .close();

当我做的时候

System.out.printline("Number of signed fields :"+numberOfSignedFields);

我得到了

Number of signed fields :0

1 个答案:

答案 0 :(得分:0)

试试这个。希望它能帮到你:

com.lowagie.text.pdf.PdfReader reader = new com.lowagie.text.pdf.PdfReader("MYPDF.pdf");

int position = reader.getAcroFields().getSignatureNames().size();