The exception you are encountering, Aspose.Pdf.PdfException: 'Signature field '3 Signature ' is not defined.', suggests that the signature field you are trying to verify does not exist in the PDF document. Here are a few steps you can take to troubleshoot and resolve this issue:
Check the Signature Field Name: Ensure that the name of the signature field you are passing to the VerifySigned method matches exactly with the name defined in the PDF. In your case, you are using "5.3 Signature ", but the error message refers to '3 Signature '. This discrepancy indicates that there might be a typo or a mismatch in the field name.
List All Signature Fields: You can list all the signature fields in the PDF to verify their names. This can help you confirm the exact name of the signature field you want to verify. Here’s a code snippet to list all signature fields:
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf("path_to_your_pdf.pdf");
foreach (var field in pdfSign.GetSignatureFieldNames())
{
Console.WriteLine(field);
}
pdfSign.Close();
Verify the Signature: Once you have confirmed the correct name of the signature field, use that name in the VerifySigned method. For example:
if (pdfSign.VerifySigned("correct_signature_field_name"))
{
Console.WriteLine("Signature Verified");
}
Check for Multiple Signatures: If your document contains multiple signatures, ensure that you are referencing the correct one. Each signature field must be uniquely named.
By following these steps, you should be able to identify the issue with the signature verification process. If the problem persists, consider checking the PDF document for any corruption or issues with the signature itself.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58243
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.