使用iText7创建自定义签名外观 [英] Create custom signature appearance with iText7

查看:96
本文介绍了使用iText7创建自定义签名外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过iText7使用我的自定义签名外观.当前,在iText中有预定义的签名外观设计.

  signatureAppearance.SetRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC_AND_DESCRIPTION); 

有人可以帮助我吗?提前致谢.问候

解决方案

您已经发现的

在iText中,有预定义的签名外观设计.

但是您还可以选择完全自己设计外观,只需从XObject检索 Layer2 即可:

  PdfFormXObject layer2XObject = signatureAppearance.GetLayer2(); 

您可以在此XObject中添加任意内容,这些内容将成为签名的可视化形式.


术语第2层"是指iText构建签名外观的方式.它模拟了Adobe Acrobat做到这一点的方式.这种方式用于允许更改外观以反映签名的验证状态,而此功能已被弃用了十多年.它还允许在字段创建过程中添加签名字段背景(在第0层"中),该签名字段背景在实际签名期间保留,根据该方案,该签名字段将使第0层保持不变.

由于签名外观仅按惯例(遵循Adobe的领导)而不是按规范包含这些层,因此,您既不应依靠检索到的签名字段具有类似的结构,也不应期望PDF处理器进一步处理PDF来尊重它们./p>

I want to use my custom signature appearance using iText7. Currently in iText there are predefined signature appearance designs.

signatureAppearance.SetRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC_AND_DESCRIPTION);

Could someone help me regarding this. Thanks in advance. Regards

解决方案

As you already found out,

in iText there are predefined signature appearance designs.

But you also have the option to design the appearance completely yourself, simply retrieve the Layer2 form XObject:

PdfFormXObject layer2XObject = signatureAppearance.GetLayer2();

To this XObject you can add arbitrary contents which will become the visualization of the signature.


The term "layer 2" refers to the way iText builds the signature appearance. It emulates the way Adobe Acrobat does this. This way used to allow changing appearances reflecting the validation status of the signature, a feature deprecated meanwhile for more than a decade. It also allows to add a signature field background (in "layer 0") during field creation which remains during actual signing which according to this scheme leaves layer 0 as is.

As a signature appearance only contains these layers by convention (following Adobe's lead) and not by specification, you should neither count on signature fields you retrieve to be structured like that nor expect PDF processors processing your PDFs further to respect them.

这篇关于使用iText7创建自定义签名外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆