我有一个由2人签名的PDF(由Eid签名)。
我正在尝试检索这些信息,但到目前为止我还不能。
这是我到目前为止所做的:
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();
}
}
}
如果我在运行期间检查'reader',我可以看到AcroForm有2个指向签名的字段,但我无法看到有关这些签名的任何特定信息。
答案 0 :(得分:9)
简短的例子:
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")
);
}