- Published on
How to remove PDF password using qpdf CLI
- Authors
- Name
- Ashik Nesin
- @AshikNesin
These days pretty much all the bank/credit card statements or anything related to finance comes under password-protected PDF.
Sometimes, you might just want to keep things simple since you'll be storing those files in a secure place anyway.
Let's see how we can remove the password from your PDF using qpdf
Dependency
You can install qpdf on Mac using brew
brew install qpdf
Refer to their docs for other operating systems.
Removing password from PDF
Once you've installed the dependency. You can remove the password and replace it with the original file with the following snippet.
qpdf --decrypt --replace-input "~/Downloads/example.pdf" --password="YourPasswordHere"
You can even create a bash script for your convenience like this
#!/usr/bin/env bash
# Usage: <file> <password> Uses qpdf to rewrite the file without encryption.
local file="$1"
local password="$2"
qpdf --decrypt --replace-input "$file" --password="$password"
And ./pdf-password-remover "~/Downloads/example.pdf" YourPasswordHere
Happy password-less pdf!