![]() |
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
(Classic ASP) 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.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% success = 0 set pdf = Server.CreateObject("Chilkat.Pdf") ' Load a PDF to be signed. success = pdf.LoadFile("c:/someDir/my.pdf") If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>" Response.End End If ' Options for signing are specified in JSON. set json = Server.CreateObject("Chilkat.JsonObject") success = json.UpdateString("subFilter","/ETSI.CAdES.detached") success = json.UpdateBool("signingCertificateV2",1) success = json.UpdateBool("signingTime",1) success = json.UpdateString("signingAlgorithm","pkcs") success = json.UpdateString("hashAlgorithm","sha256") ' ----------------------------------------------------------- ' The following JSON settings define the signature appearance. success = json.UpdateInt("page",1) success = json.UpdateString("appearance.y","top") success = json.UpdateString("appearance.x","left") success = json.UpdateString("appearance.fontScale","10.0") success = json.UpdateString("appearance.text[0]","Digitally signed by: cert_cn") success = json.UpdateString("appearance.text[1]","current_dt") success = json.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. set cert = Server.CreateObject("Chilkat.Cert") success = cert.LoadPfxFile("c:/myPfxFiles/myPdfSigningCert.pfx","pfxPassword") If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>" Response.End End If ' Once we have the certificate object, tell the PDF object to use it for signing success = pdf.SetSigningCert(cert) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>" Response.End End If ' Sign the PDF, creating the output file. outFilePath = "c:/someDir/mySigned.pdf" success = pdf.SignPdf(json,outFilePath) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>" Response.End End If Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>" %> </body> </html> |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.