Thursday, May 24, 2012

Combining and encrypting PDF files

So I need to send some documents to the guy at the bank; these documents of course have sensitive information -- account numbers at a brokerage, things like this. The bank guy also wants me to sign something and send it back to him. How to take care of everything in one go?

First, I printed the document needing signatures, and signed it, and scanned it in using xsane; I have version 0.997 on my OpenSUSE 11.3 desktop. The scanner can save as ".png" (lossless) and I convert it to PDF using imagemagick:

$ convert scanned.png scanned.pdf

The statements from the brokerage had creative filenames like Statement_03-31-12_3336.pdf and Statement_04-30-12_3336.pdf. So what I wanted to do was combine these three files into a single encrypted PDF:

  1. scanned.pdf
  2. Statement_03-31-12_3336.pdf
  3. Statement_04-30-12_3336.pdf
Here's the incantation that did it:
$ pdftk scanned.pdf Statement_0*.pdf cat output out.pdf encrypt_128bit user_pw MyPassWord
  • pdftk
    is the fabulous PDF toolkit program
  • scanned.pdf Statement_0*.pdf
    is the list of files to be combined
  • cat output out.pdf
    tells pdftk to concatenate the preceding files, and put the output into the file named out.pdf
  • encrypt_128bit user_pw MyPassWord
    means to encrypt the file using the password MyPassWord
It wasn't hard, but I needed some searching and trial-and-error to figure it out. Next time I'll just pull this little post up.

No comments: