I am trying to sign pdf documents using Aspose.Pdf version 22.1 and Adobe Reader does not validate the signature, producing the following remark: “Document has been altered or corrupted since it was signed” n Page(s) Modified.
the code I use for signing the documents is as follows:
using (FileStream fs = new FileStream(sourceFilename, FileMode.Open, FileAccess.ReadWrite))
{
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(fs))
{
Aspose.Pdf.Forms.SignatureField signatureField = new Aspose.Pdf.Forms.SignatureField(doc.Pages[1], new Aspose.Pdf.Rectangle(1, 1, 1, 1));
signatureField.Name = "SignatureField_DC";
try
{
Aspose.Pdf.Forms.ExternalSignature externalSignature = new Aspose.Pdf.Forms.ExternalSignature(getX509Certificate(certificateIdentifier))
{
Authority = Value_Signature_Author,
Location = Value_Signature_Location,
Reason = Value_Signature_Reason
}
signatureField.PartialName = Value_Signature_Field_Name;
doc.Form.Add(signatureField, 1);
signatureField.Sign(externalSignature);
doc.Save();
}
catch(Exception e)
{
diagnostics.Write(e);
}
}
}
the certificate is a valid certificate issued by a national certification authority and it is extracted from the local personal store.
This code was working correctly in 2019, but it results in the error described when used now