c# - IText:无法设置 PdfSignatureAppearance 的 СryptoDictionary 属性
问题描述
有一个使用 iTextSharp 的代码:
PdfReader reader = new PdfReader(document);
PdfStamper st = PdfStamper.CreateSignature(reader, new FileStream(document + "_signed.pdf", FileMode.Create, FileAccess.Write), '\0');
PdfSignatureAppearance sap = st.SignatureAppearance;
// something
PdfSignature dic = new PdfSignature(filterName, PdfName.ADBE_PKCS7_DETACHED);
sap.CryptoDictionary = dic;
我需要使用 iText7 编写它:
PdfReader reader = new PdfReader(@"C:\Users\RakuVIu\Documents\rozha.pdf");
PdfSigner signer = new PdfSigner(reader, new FileStream(document + "_signed.pdf", FileMode.Create), new StampingProperties());
PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
// something
PdfSignature signature = new PdfSignature(filterName, PdfName.Adbe_pkcs7_detached);
appearance.SetCryptoDictionary(signature); // no such method!
所以,我不能设置 CryptoDictionary 属性,因为没有方法或属性可以做到这一点。
解决方案
iText 7 签名 API 试图隐藏自 5.3.x 签名 API 大修以来不应再使用的实现细节,而签名字典就是这样一个细节。
关于 5.3.x 版本中引入的签名 API 的详细信息,请阅读iText 数字签名白皮书。那里的 Java 示例已移植到 C#,可以在此处访问。
推荐阅读
- asp.net-mvc - 上传种子数据时出错?
- selenium-webdriver - selenium chromedriver 和 chrome 二进制即使它们匹配版本也不会连接
- python - 为什么我在 vscode 中使用 pygame 而在 pycharm 中没有出现错误?
- python-3.x - Tkinter - 背景部分透明
- ios - 在 Windows 上运行 .ipa 应用程序
- amazon-web-services - AWS 备份查询 (EC2/EBS)
- filter - 仅在两个表之间使用内部联接,无法过滤“正确”的数据库列
- python - 密集层无法识别输入形状,即使它应该
- java - 我的 JfxListView 的自定义单元工厂返回原始对象
- json - 如何将一个json双列表在线解析成flutter中的dart?