pdf文件上不同类型的签名 [英] Different types of signature on pdf file

查看:192
本文介绍了pdf文件上不同类型的签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码对pdf文件签名(我使用itextsharp):

I sign the pdf files with this code (I use itextsharp):

            Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser();
            Org.BouncyCastle.X509.X509Certificate[] chain = new Org.BouncyCastle.X509.X509Certificate[] { cp.ReadCertificate(cert.RawData) };
            IExternalSignature externalSignature = new X509Certificate2Signature(cert, "SHA-256");
            PdfReader pdfReader = new PdfReader("testin.pdf");
            FileStream signedPdf = new FileStream("testout.pdf", FileMode.Create);  
            PdfStamper pdfStamper = PdfStamper.CreateSignature(pdfReader, signedPdf, '\0');
            PdfSignatureAppearance signatureAppearance = pdfStamper.SignatureAppearance;
            signatureAppearance.Reason = "Sign pdf";
            signatureAppearance.Location = "Location test";
            signatureAppearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.DESCRIPTION;
            MakeSignature.SignDetached(signatureAppearance, externalSignature, chain, null, null, null, 0, CryptoStandard.CMS);
            signedPdf.Close();

一切正常,这是我使用Acrobat Reader(* IMG1)打开文件时看到的内容:

Everything works perfectly and this is what I see when opening the file with Acrobat Reader (*IMG1):

现在,我收到了由其他人签名的pdf文件,并在页面末尾显示了该文件(* IMG2):

Now I'm getting pdf signed by others that display this at the end of page (*IMG2):

单击签名可打开属性(* IMG3):

Clicking on the signature opens the properties (*IMG3):

这些属性与以前的属性有些不同,随我的签名一起插入,但是除此之外,我想知道为什么我的签名出现在侧面板中,而我在其他文件中找到的却位于页面底部,并且立即可见. 我如何在页面上显示我的签名,如图像(* IMG2)所示?

These properties are a bit different from the previous ones, inserted with my signature, but apart from that, I would like to know why my signature goes in the side panel and instead the one I find in the other files is located at the bottom of the page and is visible immediately. How can I show my signature on the page as shown in the image (*IMG2)?

推荐答案

我想知道为什么我的签名出现在侧面板中,而我在其他文件中找到的那个签名位于页面底部,并且立即可见.我如何在页面上显示我的签名,如图像(* IMG2)所示?

I would like to know why my signature goes in the side panel and instead the one I find in the other files is located at the bottom of the page and is visible immediately. How can I show my signature on the page as shown in the image (*IMG2)?

您的签名在文档中没有可视化,因为您将其创建为不可见的签名(肯定不可见)!如果要创建可见的签名,则必须告诉iText该可视化将在何处进行.使用PdfSignatureAppearance方法SetVisibleSignature:

Your signature has no visualization in the document because you created it as an invisible signature (firma invisibile)! If you want to create a visible signature, you have to tell iText where that visualization shall go. You do that using the PdfSignatureAppearance method SetVisibleSignature:

PdfSignatureAppearance signatureAppearance = pdfStamper.SignatureAppearance;
signatureAppearance.SetVisibleSignature(new iTextSharp.text.Rectangle(20, 10, 170, 60), 1, "FieldName");

但是请注意,您显示的图像

Beware, though, the image you show

带有绿色勾号的图标似乎使用的是Adobe Acrobat功能,该功能已在2003年弃用,并且在ETSI TS 102 778-6和ISO 32000-2中被禁止,签名验证结果显示在以下位置:文档签名可视化.

with that green tick looks like it probably uses an Adobe Acrobat feature that has already been deprecated in 2003 and forbidden in ETSI TS 102 778-6 and in ISO 32000-2, the display of the signature validation result in the in-document signature visualization.

此类签名最终可能被视为可疑甚至无效

Such signatures may eventually be considered fishy or even invalid

这篇关于pdf文件上不同类型的签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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