Tuesday, 14 August 2007

Encrypting PDF documents and setting document permissions

Nowadays many applications are able to create PDF files. Most of them do not support advanced PDF features like encrypting PDF files or setting document permissions.

Document permissions are settings that configure what the user is allowed to do with a PDF file (let's say you can forbid the user to print the PDF file or to extract images from the PDF).

PoDoFo includes now a nice commandline utility in its SVN version (and in the next relase 0.6.0) called podofoencrypt.

podofoencrypt can be used to encrypt any existing PDF file and set document permissions on the file. You can select between weak rc4v1 encryption and strong rc4v2 encryption. An owner password has always to be set. The owner password is only used internally by PDF processing applications. The optional user password can be used if you want the user to have to enter a password before he can view the PDF in a user application.

Let's see a small example on howto use podofoencrypt to encrypt a PDF file with a user password which allows the user to print the PDF but not to extract text or images from it.

./podofoencrypt -o dominik -u user --print example.pdf output.pdf

A quick look at the document properties dialog in Adobe Reader shows that you are allowed to print the PDF but do nothing else with it.

I would like to get some feedback on the new encryption feature of PoDoFo and especially on the new podofoencrypt tool. So please get it from svn and try it out.