我有一个带签名字节的数组和一个带ocsp字节的数组,以便将ltv信息添加到我的pdf中。签名是时间戳签名。现在,我尝试将此信息添加到PDF文件与用iText添加单独的签名和单独的ocsp字节到PDF
//add signature
PdfLiteral pdfLiteral = (PdfLiteral) pdfSignature.get(PdfName.CONTENTS);
byte[] outc = new byte[ (pdfLiteral.getPosLength() - 2)/2 ];
Arrays.fill(outc, (byte) 0);
System.arraycopy(externalSignature, 0, outc, 0, externalSignature.length);
PdfDictionary dic2 = new PdfDictionary();
PdfString pdfString = new PdfString(outc).setHexWriting(true);
dic2.put(PdfName.CONTENTS, pdfString);
pdfSignatureAppearance.close(dic2);
工程...
//add LTV
for (String sigName : stamper.getAcroFields().getSignatureNames()) {
addVerification = validation.addVerification(
sigName, // Signature Name
ocspColl, // OCSP
crlColl, // CRL
null // certs
);
}
validation.merge();
stamper.close();
OK,这个工程。但在签名我必须设置标志认证级别1(不允许更改),我的应用程序将无法工作。因为添加LTV我会更改文档。我尝试创建自己的DSS字典并将其添加到我的文档中,但失败了。 任何人都可以帮忙吗?在此先感谢
布鲁诺,非常感谢这个详细的答案! – FenFen