Example code is for an older version of Toolkit, newer code is available.
<!-- Copyright (c) 2021 ActivePDF, Inc. -->
<!-- ActivePDF Toolkit 2017 -->
<!-- Example generated 01/20/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");
// Toolkit can directly encrypt an existing PDF file
// !NOTE: Evaluation keys will append 'DEMO' to the start of the password
// Encrypt a PDF with the specified encryption level
intEncryptPDF = oTK.EncryptPDF(5, strPath & "PDF.pdf", strPath & "Encrypted.pdf", "UserPassword", "OwnerPassword", true, true, false, false, true, false, true, true);
if(intEncryptPDF != 0) {
Error("EncryptPDF", intEncryptPDF);
}
// Release Object
oTK = 0;
// Process Complete
WriteOutput("Done!");
// Error Handling
Function Error(method, outputCode) {
WriteOutput("Error in " & method & ": " & outputCode);
}
</CFSCRIPT>