Without knowning the password, you cannot open it, not to mention printing, editing or copying. With this password, the whole file is encrypted. The first type of password is called Open Password or User Passwords. There are two types of protection and password, one for opening, and one for printing, editing and copying. Here's an example for zsh: decryptpdf() ' (Don't use this if you want to preserve the original, password-protected file.)įor convenience, you could create a shell function for this. -replace-input instructs qpdf to modify the original PDF in place, rather than creating a separate decrypted PDF.This is preferable to passing it directly as a command line argument, which would leak the password into the process table and shell history. -password-file=- instructs qpdf to read the password from standard input.qpdf -decrypt -password-file=-replace-input my_file.pdf Type the PDF password into the terminal, then press Enter followed by Ctrl + D to insert an EOF character. As soon as you run it, qpdf will wait for you to enter the PDF password. Then, with your encrypted PDF file at hand (we'll call it my_file.pdf), run the command below in the terminal. Joe Trellick's answer is excellent, but I would tweak it as follows for improved security.įirst, install qpdf via Homebrew by entering the following into the terminal: brew install qpdf