Removing a password from a PDF on Linux

I just bought a PDF, legally, from a publisher's website. However, in their wisdom, they decided it would be a good idea to password protect all legally-purchased PDFs. This means that each time you open the PDF using Acrobat Reader, you have to remember and type in the password to read it. (Evince, the built-in PDF viewer in Linux, allows you to permanently save the password, but I tend to use Acrobat as it copes better with some PDFs.)

So, if you know the password for a PDF and want to remove it, you can use the command line tools pdftops and ps2pdf to free your PDF from its chains.

  • Install pdftops. On Ubuntu, you can do:
    apt-get install xpdf-utils
  • Install ps2pdf. I think this is already included with a default Ubuntu.
  • Convert the PDF to a postscript file, using the password:
    pdftops -upw <password> <file>.pdf
  • Convert the resulting postscript (which is now sans password) back to a PDF:
    ps2pdf <file>.ps

The only thing you lose are any PDF-specific features which don't translate to postscript, e.g. hyperlinks.

Remember, this only works if you know the password for the PDF: it doesn't break the PDF password for you.

Comments

Thanks elliot.

Thanks elliot.

This helped me

This helped me ... Thanks

Thanks

It was really handy thanks

opensuse works great

opensuse 11.1 KDE version has ALL of those programs already pre-installed. This tut worked perfectly for my password protected PDF. Thanks for posting!

Felipe

Glad to be of assistance :)

Glad to be of assistance :)

wine app

Hi, I tried using the PDF to PS then PS to PDF method but I found the resulting pdf quality unsatisfactory, ( loss of bookmarks navigation, page sizing wrong, resolution pixelated etc...)

I ended up using this windows app:

http://www.a-pdf.com/security/restrictions_remover.htm

and installed it on Ubuntu under Wine ( https://help.ubuntu.com/community/Wine )

The pdf tool trial version is fully functional for 15 days

It worked fine and was a very simple process.

The resulting PDF was unlocked and a perfect clone of the original.

Note: I used this on an E-Book I've just purchased and have the rights to. I just don't like entering my password everytime I open it! :-)

Sounds like a good solution.

Sounds like a good solution.

what permissions

does this pdftops,pstopdf scheme allow me to modify the permissions of the file? for example, if the PDF does not allow me to print me, can I modify this setting?

Better use pdftk

Pdftk is a packaged on Debian an should be in many other distributions.
If not, it can be downloaded at http://www.accesspdf.com/pdftk/

apt-get install pdftk
pdftk secured.pdf input_pw foopass output unsecured.pdf

As ps is not used, links are not lost and pdftk can do much more for you.

But pdftk needs OWNER

But pdftk needs OWNER password and to use the method decribed above you only need USER pass.

qpdf

qpdf can decrypt a file with password. And don't have to depend on java crap.

Thank you!

Thank you!

+1 for qpdf

qpdf ftw! works like a charm, and keeps all the fancy pdf attributes like index etc.

Thanks for clarifying.

Thanks for clarifying.

Aha, great! I hadn't heard

Aha, great! I hadn't heard of that application.

Ubuntu

I don't know about the other distro's but in Ubuntu but if you know the password you can simply open up the PDF and then print to file (pdf)

Just reprint as PDF?

Not quite. A lot of secure PDFs will not print even after a password has been used successfully to open them.

As an Ubuntu user, I found the qpdf package mentioned above to be the best solution;
qpdf --password=********* --decrypt secure_version.pdf new_derypted_version.pdf

That's a tip FTW. Thx man.

That's a tip FTW. Thx man. How I'm not thought this before?

nice

Thanks for the tip :)