Tags

, , , , ,

There are a few command line tools to encrypt/ password-protect a file, for example OpenSSL, GnuPG. However, if you want to send someone an encrypted PDF who does not have access to these CLI tools, then that’s not cool for the recipient at all! Pdftk is another open-source command line tool that can encrypt a PDF file which can be decrypted using either Pdftk in the commandline or entering the password in a GUI pop-up box when the recipient tries to open the PDF file using a PDF viewer (for example, Adobe Reader).

Examples (taken from PDF Labs):

1. Encrypt a PDF using 128-Bit Strength (the Default) and Withhold All Permissions (the Default)

$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foopass

2. Same as Above, Except a Password is Required to Open the PDF

$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz

3. Same as Above, Except Printing is Allowed (after the PDF is Open)

$ pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz allow printing

4. Decrypt a PDF

$ pdftk secured.pdf input_pw foopass output unsecured.pdf


NOTE:
Setting an owner password prevents the document from being modified unless the password is provided. In the same way, setting a user password prevents the user to view the file.

Advertisements