我使用iText 5.4 PDFStamper在我的PDF文档上使用以下代码进行数字签名:
stamper = PdfStamper.createSignature(reader, os, '\0', null, true);
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setReason("SANABRIA.");
appearance.setVisibleSignature(new Rectangle(72 + 88 * (numeroFirma - 1), 732, 144 + 88 * (numeroFirma - 1), 780), 1, nombreCertificado);
ExternalSignature es = new PrivateKeySignature(privateKey, "SHA-256", "BC");
ExternalDigest digest = new BouncyCastleDigest();
MakeSignature.signDetached(appearance, digest, es, certificates, null, null, null, 0, MakeSignature.CryptoStandard.CMS);
生成签名并在PDF中正确显示:
由jsanabria数字签名
日期:2015.04.28 18:23:23 BOT
原因:SANABRIA
但我需要的是将标签更改为西班牙语,以便在PDF上得到很好的印记,即:
以数字方式签署 Firmado digitalmente por ,日期 Fecha 以及Razón的原因
Firmado digitalmente por jsanabria
Fecha:2015.04.28 18:23:23 BOT
Razón:SANABRIA
请帮助,因为我可以更改标签的语言,谢谢。
答案 0 :(得分:4)
您可以为签名外观指定任何自定义文本:
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setReason("SANABRIA.");
appearance.setVisibleSignature(new Rectangle(72 + 88 * (numeroFirma - 1),
732, 144 + 88 * (numeroFirma - 1), 780), 1, nombreCertificado);
// Custom signature appearance text
appearance.setLayer2Text("Firmado digitalmente ...");