Many service providers have started encrypting the statements that they send you. While at some level, it does add some amount of security when the path to your inbox is not very secure. However, it is sometimes a major pain when you want to archive your emails. This is because every provider has decided on a different secret to encrypt your PDF. So if one day you wish to access a statement of your phone bill from three months back, you have to look up the bill from your archive and read the mail to find out what they used to encrypt it. With my credit card statements, phone bills etc coming in as encrypted PDFs, archiving them all becomes a major pain.
So I decided to only archive un-encrypted PDF statements from now on. I consider this as a very legitimate reason to bypass PDF encryption and do not see any legal (or at least moral) reason for doing so. So you corporate lawyers looking for a DMCA victim, get out of my face.
For years, I have been using pdftk on my Ubuntu systems to manipulate PDFs. However, it being written in Java, installing it pulls in, among other things, the gcj runtime, etc. It was a minor irritation all this while. However, things finally came to a head when it refused to decrypt my credit card statement. PDFs have the concept of an owner password and an user password. The person who creates the PDF can set either one or both. Apparently, the ICICI credit card statements come with an owner password apart from an user password., and pdftk refused to decrypt the pdf without the owner password while all I had was the user password.
I searched around the net, and discovered another pdf manipulation gem, lying in the Ubuntu repositories no less, which can do what I want: QPDF.
So here is how I went around decrypting my statement.
$ sudo apt-get install qpdf
$ qpdf --decrypt --password=mypassword input.pdf output.pdf
$ evince output.pdf #to check if it asks for password
That is it!


very nice tool!
thx
Nice article Sandip,
Infact i setup a README.txt in every archive to remember password, which is no good if anyone got access to data.
This sounds great to me, i will surely experiment & get rid of pdf passwords, pain so many.. around
My company does in payslips encrypt with, employee no + date of birth, my bank statement does – my name + last 4 digits of card and sooon.
All crap,
Finally GNU/Linux rocks!
yash@yash-desktop:~/IN/2008$ qpdf –decrypt –password=xxxx 129686_December2008.pdf 129686_December_2008.pdf
129686_December2008.pdf: offset 131383: Unsupported /R or /V in encryption dictionary
yash@yash-desktop:~/IN/2008$ qpdf –check 129686_December2008.pdf
129686_December2008.pdf: offset 131383: Unsupported /R or /V in encryption dictionary
I am getting above error, sandip, compilation went OK( I needed to install libpcre++-dev, for pcre.h ), not sure what is wrong, any clue?
Very nice Article.
It worked perfectly.
Thank you very much
Pingback: QPDF: Encriptar, desencriptar e inspeccionar pdf desde consola « Un Bioinformatiquillo
do you have a dollar sign in your password? I ran into this and discovered you need to escape the dollar sign with a backslash.
I tried this on my HDFC card statement and got this:
WARNING: hdfc.pdf: offset 0: file is damaged
WARNING: hdfc.pdf: offset 12694: xref syntax invalid
WARNING: Attempting to reconstruct cross-reference table
WARNING: hdfc.pdf: offset 10012: expected endobj
qpdf: operation succeeded with warnings; resulting file may have some problems
The resulting PDF file had no text. On a Citibank card:
WARNING: citibank.pdf: offset 0: file is damaged
WARNING: citibank.pdf: can't find startxref
WARNING: Attempting to reconstruct cross-reference table
qpdf: operation succeeded with warnings; resulting file may have some problems
This file opened fine.
I tried this on my HDFC card statement and got this:
WARNING: hdfc.pdf: offset 0: file is damaged
WARNING: hdfc.pdf: offset 12694: xref syntax invalid
WARNING: Attempting to reconstruct cross-reference table
WARNING: hdfc.pdf: offset 10012: expected endobj
qpdf: operation succeeded with warnings; resulting file may have some problems
The resulting PDF file had no text. On a Citibank card:
WARNING: citibank.pdf: offset 0: file is damaged
WARNING: citibank.pdf: can't find startxref
WARNING: Attempting to reconstruct cross-reference table
qpdf: operation succeeded with warnings; resulting file may have some problems
This file opened fine.
much better and easy option in any os , which I do
open the encoded pdf in pdf reader ,
print the opened pdf with pdf printer ( I use pdf Creator )
the output file is without restriction !
note: adobe reader does not allow pdf to be reprinter with pdf printers !
Thanks for sharing this!
It's great for batch processing multiple files that have the same encrypted password:
1. Put your pdf's into a folder and create a new file in there
2. Edit the new file and input a bash script code:
#!/bin/bash
for file in * ; do
file2=`echo $file | sed “s/.pdf/_unenc.pdf/”`
qpdf –decrypt –password=password_of_files $file $file2
done
3. Make it executable: chmod +x newfilename
4. Run it!
I always find it interesting to make scripts smaller.
You can use one of bash's features here to do what sed is doing.
for file in *.pdf; do qpdf –decrypt –password=PASSWORD ${file/.pdf/_unenc.pdf}; done