Adobe ColdFusion 8

Encrypting PDF files

When you specify the protect action for a PDF file, ColdFusion encrypts the file with the RC4 128-bit algorithm by default. Depending on the version of Acrobat running on the ColdFusion server, you can set the encryption to protect the document contents and prevent search engines from accessing the PDF file metadata.

You can change the encryption algorithm by using the encrypt attribute. For a list of supported encryption algorithms, see cfpdf in the CFML Reference.

The following example changes the password encryption algorithm to RC4 40-bit encryption:

<cfpdf action="protect" source="confidential.pdf" destination="confidential.pdf"
    overwrite="yes" newOwnerPassword="paSSword1" newUserPassword="openSesame"
    encrypt="RC4_40">

To prevent ColdFusion from encrypting the PDF document, set the encryption algorithm to none, as the following example shows:

<cfpdf action="protect" source="confidential.pdf" encrypt="none" destination="public.pdf">

To decrypt a file, provide the owner or user password and write the output to another file. The following code decrypts the confidential.pdf file and writes it to a new file called myDocument.pdf:

<cfpdf action="write" source="confidential.pdf" password="paSSword1"
    destination="myDocument.pdf">