Verify Signature in PDF File
Contents
[
Hide
]
Verify Whether the PDF File is Signed Using a Signature
To verify whether a PDF file is signed using VerifySigned method of the PdfFileSignature class. This method requires the signature name and returns true if the PDF is signed using that signature name. It is also possible to verify that a PDF is signed, without verifying which signature it is signed with.
Verifying that a PDF is Signed with a Given Signature
The following code snippet shows you how to verify whether PDF is signed using a given signature.
public static void IsPdfSigned() {
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.bindPdf(_dataDir + "DigitallySign.pdf");
if (pdfSign.containsSignature())
System.out.println("Document Signed");
pdfSign.close();
}
Verifying that a PDF is Signed
To determine if a file is singed, without providing the signature name, use the following code.
public static void IsPdfSignedWithGivenSignature() {
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.bindPdf(_dataDir + "DigitallySign.pdf");
if (pdfSign.verifySigned("Signature1")) {
System.out.println("PDF Signed");
}
}
Verify whether the Signature is Valid
VerifySignature method of PdfFileSignature class allows you to validate a particular signature. This method requires signature name as input and returns true if the signature is valid. The following code snippet shows you how to validate a signature.
public static void IsPdfSignatureValid() {
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.bindPdf(_dataDir + "DigitallySign.pdf");
if (pdfSign.verifySignature("Signature1")) {
System.out.println("Signature Verified");
}
}