![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) Sign PDF using PAdES-Baseline-BSee more PDF Signatures ExamplesPAdES-Baseline-B is the most basic, entry-level profile of the PDF Advanced Electronic Signatures (PAdES) standard. It means:
In short: Baseline-B = a standard PDF digital signature that ensures integrity and origin, but without time or revocation guarantees.
#include <CkPdfW.h> #include <CkJsonObjectW.h> #include <CkCertW.h> void ChilkatSample(void) { bool success = false; CkPdfW pdf; // Load a PDF to be signed. success = pdf.LoadFile(L"c:/someDir/my.pdf"); if (success == false) { wprintf(L"%s\n",pdf.lastErrorText()); return; } // Options for signing are specified in JSON. CkJsonObjectW json; json.UpdateString(L"subFilter",L"/ETSI.CAdES.detached"); json.UpdateBool(L"signingCertificateV2",true); json.UpdateBool(L"signingTime",true); json.UpdateString(L"signingAlgorithm",L"pkcs"); json.UpdateString(L"hashAlgorithm",L"sha256"); // ----------------------------------------------------------- // The following JSON settings define the signature appearance. json.UpdateInt(L"page",1); json.UpdateString(L"appearance.y",L"top"); json.UpdateString(L"appearance.x",L"left"); json.UpdateString(L"appearance.fontScale",L"10.0"); json.UpdateString(L"appearance.text[0]",L"Digitally signed by: cert_cn"); json.UpdateString(L"appearance.text[1]",L"current_dt"); json.UpdateString(L"appearance.text[2]",L"Hello 123 ABC"); // -------------------------------------------------------------- // Load the signing certificate. (Use your own certificate.) // Note: There are other methods for using a certificate on an HSM (smartcard or token) // or from other sources, such as a cloud HSM, a Windows installed certificate, // or other file formats. CkCertW cert; success = cert.LoadPfxFile(L"c:/myPfxFiles/myPdfSigningCert.pfx",L"pfxPassword"); if (success == false) { wprintf(L"%s\n",cert.lastErrorText()); return; } // Once we have the certificate object, tell the PDF object to use it for signing success = pdf.SetSigningCert(cert); if (success == false) { wprintf(L"%s\n",pdf.lastErrorText()); return; } // Sign the PDF, creating the output file. const wchar_t *outFilePath = L"c:/someDir/mySigned.pdf"; success = pdf.SignPdf(json,outFilePath); if (success == false) { wprintf(L"%s\n",pdf.lastErrorText()); return; } wprintf(L"Success.\n"); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.