Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在不验证签名的情况下确定pdf文件是否具有c#格式的数字签名_C#_File_Digital Signature - Fatal编程技术网

在不验证签名的情况下确定pdf文件是否具有c#格式的数字签名

在不验证签名的情况下确定pdf文件是否具有c#格式的数字签名,c#,file,digital-signature,C#,File,Digital Signature,有没有办法检查PDF文件是否具有数字签名?库提供了一种功能,可以在不验证PDF文件的情况下检查PDF文件是否具有数字签名。您可以从NuGet Package Manager获得免费的Spire.PDF dll,并参考以下代码 //Load PDF file PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("Input.pdf"); //Gets the loaded form in the PDF file PdfFormWidget

有没有办法检查PDF文件是否具有数字签名?

库提供了一种功能,可以在不验证PDF文件的情况下检查PDF文件是否具有数字签名。您可以从NuGet Package Manager获得免费的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!");
    }
}
//加载PDF文件
PdfDocument pdf=新PdfDocument();
LoadFromFile(“Input.pdf”);
//获取PDF文件中加载的表单
PdfFormWidget form=pdf.form作为PdfFormWidget;
//确定表单字段中是否有签名字段,以及是否包含数字签名
for(int i=0;i

注:我是Spire的员工。

您使用什么签名格式?使用CMS/CAdES,您可以查看第一个字节是否为ASN.1。使用XMLDsig,您可以看到它是否包含数字签名的XSD。对于PDF,您应该转到签名的保留字节。对于大文件,我建议使用分离的签名文件实际上,目前的问题太广泛了。您甚至可以在特定的位置拥有自己的带有签名的文件格式。对于一块数据是否包含签名没有一般意义——它是特定于文件格式的。是的,我同意这个问题太宽泛了,我编辑了。现在这个问题已经离题了。PDF已经支持数字签名。你要求人们推荐一个C#的PDF库,它可以告诉你文件是否包含签名。你试过谷歌搜索吗?此外,在没有验证的情况下简单地检查签名的存在又有什么意义呢?你打算接受仍然包含原始签名的修改过的文档吗?顺便说一句,如果你在谷歌上搜索
PDF C#signature
,第一个结果就是一个如此的问题,链接到iTextSharp。还有许多其他选择