Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loPdf
LOCAL loSigInfo
LOCAL lnNumSignatures
LOCAL lnValidated
LOCAL loCert
LOCAL i
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loPdf = CreateObject('Chilkat.Pdf')
* Load a PDF that has cryptographic signatures to be validated
lnSuccess = loPdf.LoadFile("qa_data/pdf/sign_testing_1/helloSigned2.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
CANCEL
ENDIF
* Each time we verify a signature, information about the signature is written into
* sigInfo (replacing whatever sigInfo previously contained).
loSigInfo = CreateObject('Chilkat.JsonObject')
* Iterate over each signature and validate each.
lnNumSignatures = loPdf.NumSignatures
lnValidated = 0
loCert = CreateObject('Chilkat.Cert')
i = 0
DO WHILE i < lnNumSignatures
lnValidated = loPdf.VerifySignature(i,loSigInfo)
? "Signature " + STR(i) + " validated: " + STR(lnValidated)
* After calling VerifySignature, you can get the signer certificate by calling
* GetSignerCert with the same index.
lnSuccess = loPdf.GetSignerCert(i,loCert)
IF (lnSuccess <> 0) THEN
? "PDF signer certificate: " + loCert.SubjectDN
ENDIF
i = i + 1
ENDDO
? "Finished."
RELEASE loPdf
RELEASE loSigInfo
RELEASE loCert