Example code is for an older version of Toolkit, newer code is available.
<!-- Copyright (c) 2021 ActivePDF, Inc. -->
<!-- ActivePDF Toolkit 2017 -->
<!-- Example generated 03/06/21 -->
<!-- Example uses the .NET DLL which requires -->
<!-- Coldfusion 8 or above -->
<CFSCRIPT>
// Get current path
strPath = ExpandPath(".") & "\";
// Instantiate Object
oTK = CreateObject(".NET", "APToolkitNET.Toolkit", "C:\Program Files\activePDF\Toolkit\DotNetComponent\2.0\APToolkitNET.dll");
// Find certificate, if it doesn't exist it will be created
// If you have an existing signature you can find it with FindCertificate
// and remove the portion of code that creates the certificate
certID = oTK.FindCertificate("John Doe", "My", 0);
if(certID < 1) {
// Certificate not found, create a certificate with Toolkit
CreateCertResult = oTK.CreateCertificate("John Doe", "Management", "Doe Enterprises", "Mission Viejo", "CA", "US", "john@doee.com", 0, "My", 365, 0, "", "");
if(CreateCertResult == 1) {
// New certificate created, find it for use
certID = oTK.FindCertificate("John Doe", "My", 0);
if(certID < 1) {
Error("FindCertificate", certID);
}
} else {
// Create certificate failed
Error("CreateCertificate", CreateCertResult);
}
}
// For this example a PDF will be created to sign
// An existing PDF could be used instead
// This signs any PDF created with OpenOutputFile
intOpenOutputFile = oTK.OpenOutputFile(strPath & "new.pdf");
if(intOpenOutputFile != 0) {
Error("OpenOutputFile", intOpenOutputFile);
}
// Tell Toolkit to sign the output PDF
oTK.SignOutputFile(certID, "Mission Viejo, CA", "Security", "949-555-1212", 1);
oTK.SetFont("Helvetica", 16);
oTK.PrintText(72, 700, "Digitally Signed PDF");
oTK.CloseOutputFile();
// Release Object
oTK = 0;
// Process Complete
WriteOutput("Done!");
// Error Handling
Function Error(method, outputCode) {
WriteOutput("Error in " & method & ": " & outputCode);
}
</CFSCRIPT>