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.



Hannes said...

pdf-permissions are "security-by-obscurity"!
anyone with the user password cann decrypt the file and ignore all DRM on it.

not only that drm is evil, also it just doesnt work the way its implemented in pdf. you should not develop tools that give the false impression of security.

chicks said...

Nice. I've toyed with commandline encryption, too, using iText java lib compiled to native. See pdfcrypt here:


Yours is a lot smaller. Would also like to see an option to determine whether a PDF is encrypted, and if so, which type (AES-128, etc).

Craig said...

Hannes is right, of course - but PDF encryption is really useful for setting a user password. Even then, it's no better (and probably worse) than just including the PDF in a strongly encrypted archive.

Nonetheless, it's a feature people want, and a part of the PDF spec. PoDoFo really has to at least support reading encrypted PDF because it's used out there, and might as well write it since it's an oft-requested feature in applications. Whether or not it's actually effective or makes sense is another issue.

Anonymous said...

hello, i emailed you but got an error. anyway here's the reg cleaner i uses, this shit is good, don't stay without protection!

Alexis said...

I know a lot of tools for work with pdf files. But couple days ago I was in unpleasant situation and entered in the Internet,where I noticed - recover pdf. It solved my issue for seconds and for free as I bore in mind.

locklizard.blogger.com said...


Encrypting your PDF documents ensure that only the intended readers can decrypt and properly read your documents. When you encrypt a PDF document with a password, a user must specify the password to open the PDF document in Adobe Reader or Acrobat. Thank you...

PDF Protection

uknowme said...

not only that drm is evil, also it just doesnt work the way its implemented in pdf. you should not develop tools that give the false impression of security.
buy and sell website

free texting

Jenice said...

I tried the suggested utility to perform this task and to my surprise I successfully encrypted a pdf document. Thank you.
digital signature PDF