![]() |
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
(AutoIt) 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.
Local $bSuccess = False $oPdf = ObjCreate("Chilkat.Pdf") ; Load a PDF to be signed. $bSuccess = $oPdf.LoadFile("c:/someDir/my.pdf") If ($bSuccess = False) Then ConsoleWrite($oPdf.LastErrorText & @CRLF) Exit EndIf ; Options for signing are specified in JSON. $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("subFilter","/ETSI.CAdES.detached") $oJson.UpdateBool("signingCertificateV2",True) $oJson.UpdateBool("signingTime",True) $oJson.UpdateString("signingAlgorithm","pkcs") $oJson.UpdateString("hashAlgorithm","sha256") ; ----------------------------------------------------------- ; The following JSON settings define the signature appearance. $oJson.UpdateInt("page",1) $oJson.UpdateString("appearance.y","top") $oJson.UpdateString("appearance.x","left") $oJson.UpdateString("appearance.fontScale","10.0") $oJson.UpdateString("appearance.text[0]","Digitally signed by: cert_cn") $oJson.UpdateString("appearance.text[1]","current_dt") $oJson.UpdateString("appearance.text[2]","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. $oCert = ObjCreate("Chilkat.Cert") $bSuccess = $oCert.LoadPfxFile("c:/myPfxFiles/myPdfSigningCert.pfx","pfxPassword") If ($bSuccess = False) Then ConsoleWrite($oCert.LastErrorText & @CRLF) Exit EndIf ; Once we have the certificate object, tell the PDF object to use it for signing $bSuccess = $oPdf.SetSigningCert($oCert) If ($bSuccess = False) Then ConsoleWrite($oPdf.LastErrorText & @CRLF) Exit EndIf ; Sign the PDF, creating the output file. Local $sOutFilePath = "c:/someDir/mySigned.pdf" $bSuccess = $oPdf.SignPdf($oJson,$sOutFilePath) If ($bSuccess = False) Then ConsoleWrite($oPdf.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Success." & @CRLF) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.