Obsidian Metadata
| date | 2026-09-14 |
| published | 2026-09-14 |
QPDF — practical reference
Setup on macOS
With Homebrew installed:
brew install qpdf
qpdf --version
Open Terminal and move into the folder containing your PDFs:
cd ~/Downloads
My working convention
Keep the original. Give outputs descriptive names such as
statement-unlocked.pdforreport-selected.pdf. Quote filenames containing spaces. Replace example filenames before running commands.
Everyday commands
These recipes follow the official QPDF command reference.
Remove a known password
qpdf --password='YOUR_PASSWORD' --decrypt "locked.pdf" "unlocked.pdf"
For sensitive passwords, use a local file containing the password on its first line:
qpdf --password-file="password.txt" --decrypt "locked.pdf" "unlocked.pdf"
Password handling
Literal passwords can remain in shell history. Keep password files and unlocked documents out of shared folders and your Obsidian vault; delete the temporary password file afterward.
Merge PDFs
qpdf --empty --pages "first.pdf" "second.pdf" -- "merged.pdf"
Extract or reorder pages
qpdf "input.pdf" --pages . 2-5 -- "extract.pdf"
qpdf "input.pdf" --pages . 3,1,2,4-z -- "reordered.pdf"
Pages start at 1; z means last page; . means the input. The closing -- ends page selection.
Remove page 3
qpdf "input.pdf" --pages . 1-2,4-z -- "without-page-3.pdf"
Split into individual pages
qpdf "input.pdf" --split-pages "page.pdf"
Rotate all pages clockwise
qpdf "input.pdf" --rotate=+90:1-z "rotated.pdf"
Try lossless compression
qpdf "input.pdf" --object-streams=generate --recompress-flate --compression-level=9 "smaller.pdf"
Savings vary; compare sizes.
Check structure or count pages
qpdf --check "input.pdf"
qpdf --show-npages "input.pdf"
Ordinary exit codes: 0 success, 2 error, 3 warnings. A structural check does not guarantee correct rendering.
Help
qpdf --help
qpdf --help=--pages
Before using the result
-
Open the output and inspect the relevant pages.
-
Confirm page order and that the expected content is present.
-
For a merged report, inspect bookmarks and forms if you rely on them.
-
Keep a separate original of any digitally signed document.
Personal examples to add later
-
Most frequent task:
-
Folder where I keep source PDFs:
-
Command that worked:

