Sign PDF using Aspose.PDF for .NET - No signature information found in output PDF

Hi Aspose team,

We are using v20.3 lib. I signed an encrypted PDF, but there are no any signature information in the generated PDF, and then I attempted to view the generated PDF using Adobe Acrobat Std 2017. Acrobat states “At least one signature is invalid”.
BTW, I didn’t see any exceptions occured in the code while signing, it means that signing the PDF should be successful.

I prepared the code sample, the test pdf and the certificate. Please have a look . Thanks.

@Glority_Developer

We were able to notice the issue in our environment with Aspose.PDF for .NET 20.4 and have logged it as PDFNET-48061 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi Aspose team,

How is the progress? Will this issue be fixed within 1-2 months? We are going to have the code freeze date of our product.

@Glority_Developer

We regret to inform you that earlier logged ticket is not yet resolved due to other issues in the queue which were logged prior. We will certainly let you know once we have additional updates regarding issue fix. We highly appreciate your patience and comprehension in this regard.

We apologize for your inconvenience.

@Glority_Developer

We have investigated the earlier logged ticket. For unknown reasons, Adobe considers PKCS7 signature invalid. Now we can recommend using PKCS7Detached. It works correctly with encryption.

var doc = new Document(dataDir + @"encrypt_123456.pdf", "123456");
var pkcs2 = new PKCS7Detached(dataDir + @"trent.pfx", "123456789");

var rect2 = new System.Drawing.Rectangle(0, 0, Convert.ToInt32(doc.Pages[1].PageInfo.Width), 100);
var signDoc = new Facades.PdfFileSignature(doc);
signDoc.Sign(1, "WinZip Reason", string.Empty, "WinZip Location", true, rect2, pkcs2);
signDoc.Save(dataDir + @"new_encryptedFile.pdf"); 

Please use the suggested code snippet with Aspose.PDF for .NET 21.9 and let us know in case you face any issues.

@asad.ali

Thanks for your investigation. We tried both Aspose.PDF for .NET 21.9 and 21.10, it still can not sign that encrypted pdf. Here is our code:

var doc = new Aspose.Pdf.Document(dataDir + @"encrypt_123456.pdf", "123456");
var pkcs2 = new Aspose.Pdf.Forms.PKCS7Detached(dataDir + @"trent.pfx", "123456789");

var rect2 = new System.Drawing.Rectangle(0, 0, Convert.ToInt32(doc.Pages[1].PageInfo.Width), 100);
var signDoc = new Aspose.Pdf.Facades.PdfFileSignature(doc);
signDoc.Sign(1, "WinZip Reason", string.Empty, "WinZip Location", true, rect2, pkcs2);
signDoc.Save(dataDir + @"new_encryptedFile.pdf");

Did we do something wrong?

@Glority_Developer

We tested in our environment using the latest version of the API and did not face any issue. Please check the attached output file generated at our end using the same code snippet. Furthermore, would you please make sure that the certificate is added to Trusted Certificate List of Adobe Reader? Also, please share the screenshot and obtained output file from your side so that we can observe it.new_encryptedFile.pdf (577.0 KB)

@asad.ali

We can’t see the signature on the Pdf but we can see it at the signature panel in Adobe Acrobat, neither the file we signed using Aspose.PDF for .NET 21.9 nor the attached file you give us. like the figure shown below :
signed_by_Aspose.png (23.7 KB)

We tried sign the same Pdf using Adobe Acrobat with the same ‘trent.pfx’ file, the signature is visible on the Pdf :
signed_by_Adobe.png (33.5 KB)

Is there a way to make the signature visible when using Aspose.PDF for .NET to sign the pdf?
PS: there are two attached files. new_encryptedFile.pdf is signed using Aspose.PDF for .NET 21.9 and adobe_signed_encrypt_123456.pdf is signed using Adobe Acrobat.
adobe_signed_encrypt_123456.pdf (630.2 KB)
new_encryptedFile.pdf (577.1 KB)

@Glority_Developer

We were able to notice the similar issue in our environment. Therefore, have logged an issue as PDFNET-50820 in our issue tracking system for further investigation. We will look into its details and let you know as soon as it is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-50820) have been fixed in Aspose.PDF for .NET 22.2.