AcroFields fields = reader.getAcroFields();
PdfPKCS7 pkcs7 = fields.verifySignature(signature);
// Use the signature to check the document integrity.
if (!pkcs7.verify()) {
throw new InvalidSignatureException(
String.format(messages.getString(
"Document_was_modified_or_corrupted_after_the_signature__%s"),
signature));
}