React Native
React Native
Get PDF Signer Certs
See more PDF Signatures Examples
This example demonstrates how to validate the signatures in a PDF and also shows how to getChilkat React Native Downloads
import { Cert, JsonObject, Pdf } from '@chilkat/react-native'
function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const pdf = new Pdf();
// Load a PDF that has cryptographic signatures to be validated
try {
pdf.loadFile('qa_data/pdf/sign_testing_1/helloSigned2.pdf');
} catch {
console.log(pdf.lastErrorText);
return;
}
// Each time we verify a signature, information about the signature is written into
// sigInfo (replacing whatever sigInfo previously contained).
const sigInfo = new JsonObject();
// Iterate over each signature and validate each.
const numSignatures = pdf.numSignatures;
let validated = false;
const cert = new Cert();
let i = 0;
while (i < numSignatures) {
validated = true;
try {
pdf.verifySignature(i, sigInfo);
} catch {
validated = false;
}
console.log(`Signature ${i} validated: ${validated}`);
// After calling VerifySignature, you can get the signer certificate by calling
// GetSignerCert with the same index.
try {
pdf.getSignerCert(i, cert);
console.log(`PDF signer certificate: ${cert.subjectDN}`);
} catch {
// pdf.getSignerCert() failed; continue anyway.
}
i++;
}
console.log('Finished.');
}