简体   繁体   English

如何检查PDF文件已签名多少次?

[英]How can I check how many times a PDF file had been signed?

How can I check how many times a PDF file had been signed, using C# and preferably iTextSharp 5.5.11? 如何使用C#(最好是iTextSharp 5.5.11)检查PDF文件已签名多少次? I'm open to any other .NET PDF library as long as it does the job. 只要能完成此工作,我就对其他任何.NET PDF库都开放。

I would like to choose a PDF file from my hard drive and show on a form how many times the PDF file had been signed. 我想从硬盘驱动器中选择一个PDF文件,并在表格上显示该PDF文件已签名多少次。

Showing the certificate source would be a bonus. 显示证书来源将是一个奖励。

Thank you. 谢谢。

Since iText exists both in Java and C# and the Digital Signatures tutorial for iText was written in the former, I will give the answer in Java and there should be no problem to port it to c#: 由于iText在Java和C#中都存在,并且iText的数字签名教程是用前者编写的,因此我将以Java给出答案,将其移植到c#应该没有问题:

One can use SignatureUtil#getTotalRevisions() to get the number. 可以使用SignatureUtil#getTotalRevisions()来获取数字。 It has been designed to give you the number of signatures in the document, or that number plus one if changes were applied after the last time the document was signed. 它的设计目的是为您提供文档中的签名数量,如果在上次签署文档后进行了更改,则该数字加一个。

Please check C5_01_SignatureIntegrity . 请检查C5_01_SignatureIntegrity Here three documents are processed: the first had been signed, but then modified, the second was signed by four persons and the third had been signed by 4 persons and then modified. 这里处理了三份文件:第一份已经签名,但随后进行了修改,第二份由四个人签名,第三份已经由4人签名,然后进行了修改。 SignatureUtil#getTotalRevisions() returns 2, 4 and 5 for them respectively. SignatureUtil#getTotalRevisions()分别为它们返回2、4和5。

The results in the first and the third cases are a bit misleading, but one can use SignatureUtil#signatureCoversWholeDocument(String) to check whether the last revision corresponds to the last signing or not. 第一种和第三种情况的结果有点误导,但是可以使用SignatureUtil#signatureCoversWholeDocument(String)来检查最后一个修订版本是否与最后一个签名相对应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM