How to use qpdf to add/remove password from pdf on mac

Sometimes we need to add or remove passwords from a pdf file. You can do it using Google Chrome or many other UI tools also. In case you need to do it more often and want to use command line, the qpdf is a good option. These are steps to add or remove passwords from a pdf on Mac. Similar instruction should also work for Linux.

First install qpdf using the following command:

$ brew install qpdf

Add password to pdf

To add password to pdf document, you can use the following command:

$ qpdf --encrypt test123 test123 40 -- doc_without_pass.pdf doc_with_pass.pdf

Note that test123 is both user and owner password here and key lenght is 40.

You can try opening the document and it should ask you to enter the password:

$ open doc_with_pass.pdf

Remove password from pdf

To remove password from pdf document, you can use the following command:

qpdf --password=test123 --decrypt doc_with_pass.pdf doc_without_pass2.pdf

This will create doc_without_pass2.pdf file which should open without a password.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments