Example code is for an older version of Toolkit, newer code is available.
<!-- Copyright (c) 2021 ActivePDF, Inc. -->
<!-- ActivePDF Toolkit 2017 -->
<!-- Example generated 01/18/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);
}
}
// Invisibly sign an existing PDF
intInvisiblySignFile = oTK.InvisiblySignFile(certID, strPath & "PDF.pdf", strPath & "new.pdf", "Mission Viejo, CA", "Security", "949-555-1212", 1);
if(intInvisiblySignFile != 0) {
Error("InvisiblySignFile", intInvisiblySignFile);
}
// Release Object
oTK = 0;
// Process Complete
WriteOutput("Done!");
// Error Handling
Function Error(method, outputCode) {
WriteOutput("Error in " & method & ": " & outputCode);
}
</CFSCRIPT>