pdfcpu command generator
Merge, split, compress, rotate, watermark, password-protect or unlock PDFs from the command line with pdfcpu — a free, open-source PDF processor that is a single file with no dependencies. Pick a job and copy the command.
·
Unofficial — pdfcpu is made by Horst Rutter and contributors (Apache-2.0). Prefer buttons to a terminal? GUI Hub’s PDF Toolkit runs these same commands from a form, offline.
Common pdfcpu commands
Merge
Combine several PDFs into one, in the order listed.
pdfcpu merge output.pdf part1.pdf part2.pdf
Split
Split a PDF into smaller files.
pdfcpu split --mode span document.pdf pages 1
Compress
Shrink a PDF by removing duplicate and unused data. Text and images stay the same quality.
pdfcpu optimize document.pdf output.pdf
Rotate
Rotate all pages or a range of pages.
pdfcpu rotate --pages 1-2 document.pdf 90 output.pdf
Watermark
Stamp text such as DRAFT or CONFIDENTIAL across every page.
pdfcpu watermark add --mode text CONFIDENTIAL 'rot:45, op:.25, scale:.8' document.pdf output.pdf
Add password
Protect a PDF with AES-256 encryption.
pdfcpu encrypt --upw open-secret --opw owner-secret document.pdf output.pdf
Remove password
Remove the password from a PDF you have the password for.
pdfcpu decrypt --upw open-secret locked.pdf output.pdf
Extract pages
Save selected pages as separate PDF files.
pdfcpu extract --mode page --pages 1-2 document.pdf pages
Questions
Does compressing a PDF here keep the text selectable?
Yes. pdfcpu optimize removes duplicate and unused data without turning pages into pictures. That keeps quality but saves less on scans; to hit a size like 100 KB, the free browser compressor re-saves pages as images instead.
Split or extract says the output folder is missing
Create it first (mkdir pages), then run the command again.
Are the passwords safe on the command line?
They end up in your shell history. Fine on your own computer; on a shared one, clear the history afterwards.
Are these the right options for my version?
They are the commands GUI Hub itself runs, and every option is checked against the real pdfcpu 0.16.4 help output on Windows, macOS and Linux in our automated tests.
Do I need to install anything?
Only pdfcpu itself (the single-file download from github.com/pdfcpu/pdfcpu/releases, or brew install pdfcpu / go install github.com/pdfcpu/pdfcpu/cmd/pdfcpu@latest). This page just writes the command; nothing is uploaded. If you’d rather not use a terminal, the GUI Hub desktop app runs the same commands from a form, offline, and its MCP server lets Claude or Cursor run them for you.
Windows: why do the quotes look different?
cmd and PowerShell don’t understand single quotes, so the Windows version wraps arguments with spaces in double quotes. Pick your system above the command.