iText:在可见签名上显示签名详细信息

发布于 2024-12-08 22:00:10 字数 262 浏览 4 评论 0原文

在当前项目中,我使用 itext 和 java 签署 pdf 文档。我还可以创建可见的签名。但现在我需要自定义可见签名。可见签名必须包含签名者的姓名、电子邮件、原因和签名日期。我能否以某种方式从证书中读取此信息并将其显示在可见印章上?我尝试使用 PdfTemplates,但没有找到引用证书数据的方法。我只能在可见签名中设置静态文本。

换句话说:是否可以选择在可见标记上显示哪些证书详细信息,而无需在 pdf 模板中设置明确的文本(使用对证书详细信息的引用,例如时间戳、DN,而不是静态文本)?

In the current project, I am signing pdf-documents with itext and java. I am also able to create a visible signature. But now I need to customize the visible signature. The visible signature have to contain the signer's name, email, reason, and the signing date. Can I somehow read this information from the certificate to display them on the visible stamp? I tried with the PdfTemplates but I didn't find a way to refrence to the certificate data. I only were able to set static text in the visible signature.

In other words: Is it possible to choose which certificate details are displayed on the visible stamp, without setting explicite text in the pdftemplates (use reference to certificatedetails like timestamp, DN, what ever instead static text)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2024-12-15 22:00:10

是和否:您可以使用 PdfSignatureAppearance.setLayer2Text() 自由设置签名可视化中的文本(您甚至可以在 PdfSignatureAppearance.getLayer(2) 上设计整个外观)但不会对变量进行评估。

因此,您必须亲自检查证书并提取信息以放入要使用 setLayer2Text 设置的字符串中。对于一些细节,您可以使用 iText 辅助类,例如 CertificateInfo 方法 getIssuerFields()getSubjectFields();对于其他人,您将需要自己的方法。但是您可以使用这些方法的代码作为您需要实现的方法的模板。

Yes and no: You can freely set the text in the signature visualization using PdfSignatureAppearance.setLayer2Text() (you can even design the whole appearance on PdfSignatureAppearance.getLayer(2)) but no evaluation of variables will take place.

So you have to inspect the certificate yourself and extract the information to put into that string you are going to set with setLayer2Text. For some details you may use iText helper classes, e.g. the CertificateInfo methods getIssuerFields() or getSubjectFields(); for others you will need your own methods. But you can use the code of those methods as a template for the methods you need to implement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文