Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Node.js) Sign PDF for ICP-BrasilSee more PDF Signatures ExamplesSign a PDF to create a signed PDF compliant with the ICP-Brasil Digital Signature Standard Conformity Checker. (Verificador de Conformidade do PadrĂ£o de Assinatura Digital ICP-Brasil) Note: This example requires Chilkat v9.5.0.92 or greater. For more information, see https://verificador.iti.gov.br/verifier-2.6.2/
var os = require('os'); if (os.platform() == 'win32') { if (os.arch() == 'ia32') { var chilkat = require('@chilkat/ck-node17-win-ia32'); } else { var chilkat = require('@chilkat/ck-node17-win64'); } } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node17-arm'); } else if (os.arch() == 'x86') { var chilkat = require('@chilkat/ck-node17-linux32'); } else { var chilkat = require('@chilkat/ck-node17-linux64'); } } else if (os.platform() == 'darwin') { var chilkat = require('@chilkat/ck-node17-macosx'); } function chilkatExample() { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // The signed PDF produced by this example should be verifiable at https://verificador.iti.gov.br/verifier-2.10/ var pdf = new chilkat.Pdf(); // Load a PDF to be signed. // The "hello.pdf" is available at https://chilkatsoft.com/hello.pdf var success = pdf.LoadFile("qa_data/pdf/hello.pdf"); if (success == false) { console.log(pdf.LastErrorText); return; } var json = new chilkat.JsonObject(); // Define the appearance and location of the signature. json.UpdateInt("page",1); json.UpdateString("appearance.y","bottom"); json.UpdateString("appearance.x","middle"); json.UpdateString("appearance.fontScale","9.0"); json.UpdateString("appearance.text[0]","Digitally signed by: cert_cn"); json.UpdateString("appearance.text[1]","current_dt"); json.UpdateString("appearance.image","document-accepted"); json.UpdateString("appearance.imagePlacement","left"); json.UpdateString("appearance.imageOpacity","100"); // Add the CMS options required for ICP-Brasil json.UpdateInt("contentType",1); json.UpdateInt("messageDigest",1); json.UpdateInt("signingCertificateV2",1); json.UpdateBool("ltvOcsp",true); // Listed here are the currently existing profiles. (Chilkat will add additional ICP Brasil policy profiles in future versions as new ones are created.) // See https://www.gov.br/iti/pt-br/assuntos/repositorio/artefatos-de-assinatura-digital for more information. // // PA_PAdES_AD_RA_v1_0 --> 2.16.76.1.7.1.14.1 // PA_PAdES_AD_RA_v1_1 --> 2.16.76.1.7.1.14.1.1 // PA_PAdES_AD_RA_v1_2 --> 2.16.76.1.7.1.14.1.2 // PA_PAdES_AD_RB_v1_0 --> 2.16.76.1.7.1.11.1 // PA_PAdES_AD_RB_v1_1 --> 2.16.76.1.7.1.11.1.1 // PA_PAdES_AD_RC_v1_0 --> 2.16.76.1.7.1.13.1 // PA_PAdES_AD_RC_v1_1 --> 2.16.76.1.7.1.13.1.1 // PA_PAdES_AD_RC_v1_2 --> 2.16.76.1.7.1.13.1.2 // PA_PAdES_AD_RT_v1_0 --> 2.16.76.1.7.1.12.1 // PA_PAdES_AD_RT_v1_1 --> 2.16.76.1.7.1.12.1.1 // Set the policy profile name json.UpdateString("policyId.profile","PA_PAdES_AD_RB_v1_1"); // Load the signing certificate. (Use your own certificate.) // Note: If loading from a smart card, call LoadFromSmartcard instead, and make sure to use Chilkat v9.5.0.88 or later. var cert = new chilkat.Cert(); success = cert.LoadPfxFile("qa_data/pfx/myPdfSigningCert.pfx","pfx_password"); if (success == false) { console.log(cert.LastErrorText); return; } // Tell the pdf object to use the certificate for signing. success = pdf.SetSigningCert(cert); if (success == false) { console.log(pdf.LastErrorText); return; } success = pdf.SignPdf(json,"qa_output/hello_signed.pdf"); if (success == false) { console.log(pdf.LastErrorText); return; } console.log("The PDF has been successfully cryptographically signed."); } chilkatExample(); |
© 2000-2023 Chilkat Software, Inc. All Rights Reserved.