简体   繁体   English

使用iTextSharp签名PDF

[英]Signing a PDF with iTextSharp

I've been using iTextSharp to sign PDFs in my application, and it works pretty good using this code I adapted from the java example on the iText website: 我一直在使用iTextSharp在我的应用程序中对PDF进行签名,并且使用从iText网站上的Java示例改编而成的以下代码,它可以很好地工作:

PdfStamper stp = PdfStamper.CreateSignature(reader, outmemstream, ControlChars.NullChar);
PdfSignatureAppearance sap = stp.SignatureAppearance;
sap.SetCrypto(prvKey, new X509Certificate[] {sigCert, Repository.CAcertificate}, null, pdfSignatureAppearance.SELF_SIGNED);
sap.Reason = "Just to proove I can sign!";

This has worked ok until version 5.2.1 of iText, but in the recent version 5.3.0 the "SetCrypto" method has been removed and I cannot sign anymore! 在iText的5.2.1版之前,此方法一直有效,但是在最新的5.3.0版中,“ SetCrypto”方法已删除,我无法再签名! Any ideas on why it has been removed and what may be an alternative method to sign a pdf on the new version?? 关于为什么要删除它的任何想法,以及在新版本上签名pdf的替代方法是什么?

Thanks in advance 提前致谢

PDF signing has been refactored in iText 5.3.0 and a white paper is currently being written about the new signing process. PDF签名已在iText 5.3.0中进行了重构,并且目前正在编写有关新签名过程的白皮书。 The final version should be published in September. 最终版本应在9月发布。

You'll find more information here . 您可以在此处找到更多信息。

该书示例已经适应iText 5.3.0: http ://itextpdf.com/book/chapter.php? id=12

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM