Example code is for an older version of Toolkit, newer code is available.
# Copyright (c) 2021 ActivePDF, Inc.
# ActivePDF Toolkit 2017
# Example generated 02/27/21
require 'win32ole'
# Get current path
strPath = File.expand_path(File.dirname(__FILE__)) + "\\"
# Instantiate Object
oTK = WIN32OLE.new("APToolkit.Object")
# 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
puts "Error in EncryptPDF: #{intEncryptPDF}"
end
# Release Object
oTK = ''
# Process Complete
puts "Done!"