如何使用itextsharp C#从签名字段中删除有效性未知图标?

时间:2019-04-24 10:13:09

标签: c# itext digital-signature acrobat pkcs#7

在计算pdf哈希之前,如何从签名字段中删除有效性未知的图标(问号)。

下面我用于创建签名字段的代码。

PdfStamper stamper = PdfStamper.CreateSignature(reader, os, '\0');
PdfSignatureAppearance appearance = stamper.SignatureAppearance;
appearance.SignDate = DateTime.Now.AddMinutes(15);
appearance.Reason = reasonForSign;
appearance.Contact = "";
appearance.Location = locationToShowOnSignatureStamp;
appearance.Acro6Layers = false;
appearance.Image = null;
appearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.DESCRIPTION;
appearance.CertificationLevel = PdfSignatureAppearance.NOT_CERTIFIED;
appearance.SetVisibleSignature(new iTextSharp.text.Rectangle(10, 10, 149, 69), reader.NumberOfPages, "s1");

1 个答案:

答案 0 :(得分:1)

您的代码明确要求该图标:您使用

appearance.Acro6Layers = false;

这指示itext像Adobe Acrobat直到版本5一样创建签名外观。这包括具有肯定,不确定或否定验证结果的签名“层”。如果您使用

appearance.Acro6Layers = true;
代替

(这是默认设置),itext创建的签名不会使Adobe Acrobat不再显示验证结果的页面可视化效果。