如何检索数字签名信息(名称,日期,...)与iTextSharp的 [英] How to retrieve digital signature information (name, date, ...) with ItextSharp
本文介绍了如何检索数字签名信息(名称,日期,...)与iTextSharp的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已签署的2人(通过EID)的PDF文件。
I have a pdf which has been signed by 2 people (by Eid).
我试图获取此信息,但我无法thusfar。
I'm trying to retrieve this information but I'm unable thusfar.
这是我到目前为止有:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string workingFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string inputFile = Path.Combine(workingFolder, "Tax Return.pdf");
PdfReader reader = new PdfReader(inputFile);
Console.ReadLine();
}
}
}
如果我检查读者在运行时我可以看到AcroForm有2场指向签名,但我无法看到这些签名的任何具体信息......
If I inspect 'reader' during runtime I can see that AcroForm has 2 Fields that point to the signatures but I'm unable to see any specific information about these signatures...
在此先感谢!
推荐答案
看看的 最好的例子使用带数字签名 工作时的iText [夏普]。这里有一个简单的例子:
Take a look at the best examples for working with digital signatures when using iText[Sharp]. Here's a short example:
StringBuilder sb = new StringBuilder();
PdfReader reader = new PdfReader(pdf);
AcroFields af = reader.AcroFields;
ArrayList names = af.GetSignatureNames();
for (int i = 0; i < names.Count; ++i) {
String name = (string)names[i];
PdfPKCS7 pk = af.VerifySignature(name);
sb.AppendFormat("Signature field name: {0}\n", name);
sb.AppendFormat("Signature signer name: {0}\n", pk.SignName);
sb.AppendFormat("Signature date: {0}\n", pk.SignDate);
sb.AppendFormat("Signature country: {0}\n",
PdfPKCS7.GetSubjectFields(pk.SigningCertificate).GetField("C")
);
sb.AppendFormat("Signature organization: {0}\n",
PdfPKCS7.GetSubjectFields(pk.SigningCertificate).GetField("O")
);
sb.AppendFormat("Signature unit: {0}\n",
PdfPKCS7.GetSubjectFields(pk.SigningCertificate).GetField("OU")
);
}
这篇关于如何检索数字签名信息(名称,日期,...)与iTextSharp的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文