Apply or remove encryption from a given PDF with a quick right-click.
[Hack #52] discussed how to apply or remove PDF encryption with pdftk [Hack #79] . Let's streamline these security operations by adding handy Encrypt and Decrypt items to the PDF context menu. The encryption example simply applies a user password to the selected PDF, so nobody can open it without the password. The decryption example removes all (Standard) security, upon success.
Windows XP and Windows 2000:
In the Windows File Explorer menu, select Tools Folder Options . . . and click the File Types tab. Select the PDF file type and click the Advanced button.
Click the New . . . button and a New Action dialog appears. Give the new action the name Encrypt.
Give the action an application to open by clicking the Browse . . . button and selecting cmd.exe, which lives somewhere such as C:\windows\system32\ (Windows XP) or C:\winnt\system32\ (Windows 2000).
Add these arguments after cmd.exe, changing the path to suit, like so:
C:\windows\system32\cmd.exe /C C:\windows\system32\pdftk.exe "%1" output "%1.encrypted.pdf" encrypt_128bits user_pw PROMPT
Click OK, OK, OK and you should be done with the configuration.
Follow the preceding procedure, except name the action Decrypt and replace the cmd.exe arguments in step 4 with:
C:\windows\system32\cmd.exe /C C:\windows\system32\pdftk.exe "%1" input_pw PROMPT output "%1.decrypted.pdf"
Right-click your PDF of interest and select Encrypt or Decrypt from the context menu. A command prompt will open and ask for the password. Upon success, the command prompt will close. pdftk will create a new PDF file with a name based on the original PDF's filename. If pdftk has trouble executing your request, the command prompt will remain open with a message. Press Enter to close this message.
If you invoke one of these commands on a selection of multiple PDFs, you will get one command prompt for each PDF.