有没有办法检查PDF文件是否有数字签名?
答案 0 :(得分:0)
Free Spire.PDF库提供了一种功能,可以检查PDF文件是否具有数字签名而无需进行验证。您可以从NuGet Package Manager获取Free Spire.PDF dll并参考以下代码。
//Load PDF file
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Input.pdf");
//Gets the loaded form in the PDF file
PdfFormWidget form = pdf.Form as PdfFormWidget;
//Determine if there is any signature field among the form fields and whether it contains digital signature
for (int i = 0; i < form.FieldsWidget.Count; i++)
{
var field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
if (field != null && field.Signature != null)
{
Console.WriteLine("This form field has digital signature!");
}
}
注意:我是Spire的员工。