PDF Encryption and printing

Ranguard on 2008-01-26T09:46:33

I happened to note that if you pass a PDF through imagemagick's 'convert', convert it strips out the PDF Encrypted flag.

I needed to merge several PDF files into a single document, and using PDF::API2 this is really easy. This was until I found that someone had accidentally set the PDF Encrypted on some of the files when they were generated.

pdfinfo is the natty little tool which told me they were encrypted. Then convert sorted the problem out for me.

PDF can be very picky and quite a few generators actually get it wrong, I've seen one file which when printed through windows corrupted some of the very small text, but when sent via CUPs actually crashed the printer (so windoz was somehow correcting, reminded me of bad HTML and browsers 'correcting').

It was eventually tracked down to the pdf2ps part, which did give warnings, once they were fixed (upgrading Cario and switching to pnm images) printing from either windoz or CUPs was fine.

Having said that I no longer fear having to generate something as a PDF and actually would go so far as to enjoy using them.


CAM::PDF and PDF::API2

ChrisDolan on 2008-01-27T18:04:28

PDF::API2 is an awesome tool. It has a nicer API than my implementation, CAM::PDF, although we are focused on slightly different problem spaces (mine has almost no support for content creation). I'm believe that PDF::API2's support for PDF encryption was inspired by my implementation -- Alfred and I swapped email on the topic a while back. The last time I checked (like 2 years ago), my implementation was faster at parsing documents and doing simple operations like merging two PDFs. However, since switching employers I have not been maintaining my distribution very thoroughly.

Re:CAM::PDF and PDF::API2

Ranguard on 2008-01-27T19:15:02

Cheers Chris, I'll remember to try CAM::PDF as well next time, speed hasn't been an issue yet, but one day it may well :)

PDF API2 suitable for password encryption?

AlainS on 2008-02-04T20:43:59

Hi Guys,

Maybe you got the answer to my question:

Selling an e-book in pdf-format, I want to secure the pdf with a password encryption. In Adobe you can do that by hand through "Secure- Password Encrypt", but I want to do this automatically by writing a perl-script. I discovered the PDF::API2 module, but I can't discover if that module also offers a password encrypt-functionality.

Reading your discussion, this does seem possible. But how to do that? Which methods of this library to use?

Thanks a lot!

Alain

Re:PDF API2 suitable for password encryption?

Ranguard on 2008-02-04T22:31:27

Not sure about the perl modules, if your on *nix then pdftk does this I think http://www.pdfhacks.com/pdftk/, I'd probably just shell out to that.

Re:PDF API2 suitable for password encryption?

runrig on 2008-02-05T00:26:03

pdftk also runs on windows.