I have found unexpected behaviour in sample DigitalSignatureTestCS_2010: PKCS7Signature.ComputeSignature() is called twice for each added signature. What is the reason for such behaviour? Is there any way how can I avoid this?
The method is invoked twice because applying the digital signature requires 2 passes. The reason for this is because PDFNet saves the document in one single pass (for effeciency). It is not until the 2nd pass (where all the required bytes for signing are written) which the actual digital signature can be correctly calculated. The 1st call of CreateSignature is necessary to determine the size to allocate for the signature.