Splitting a PDF from the command line is fast, scriptable, and preserves the original quality of every page. Use qpdf, pdfseparate, or pdftk. Each gives you precise control without a graphical interface, and all three work on Linux and macOS.
Why Use the Command Line to Split PDFs
Command-line tools copy page objects without re-rendering. Text and images keep their original fidelity. Output files are produced quickly. When you need to split many PDFs or integrate splitting into a shell script, a terminal-based approach is more efficient than clicking through a GUI each time.
Three utilities cover most needs: qpdf, pdfseparate (from Poppler), and pdftk. Install them with standard package managers.
Installing the Tools
Install the tools before you start. The commands differ by operating system:
- macOS: Use Homebrew. Run brew install qpdf poppler to get both qpdf and pdfseparate (from poppler).
- Debian/Ubuntu: Use apt. Run sudo apt install qpdf poppler-utils to install qpdf and pdfseparate.
- pdftk: This is a separate package. On Debian/Ubuntu, install it with sudo apt install pdftk (package name may vary by distribution). On macOS, try brew install pdftk or download it from the official site.
After installation, verify the tools are available by typing qpdf --version, pdfseparate -v, or pdftk --version in your terminal.
Splitting with Qpdf
qpdf is powerful, free, and open-source. It splits a PDF into individual pages or into chunks of a specified size.
Split Into One File per Page
Use the --split-pages option with an output pattern. The %d is a placeholder for the page number.
qpdf --split-pages input.pdf out-%d.pdfThis command creates files like out-1.pdf, out-2.pdf, and so on.
Split Into Chunks of a Specific Size
To make each output file contain a fixed number of pages, add an equals sign and the number after --split-pages. For five-page chunks:
qpdf --split-pages=5 input.pdf out-%d.pdfThis produces out-1.pdf with pages 1-5, out-2.pdf with pages 6-10, and so on.
Extract a Page Range
qpdf also extracts a specific range of pages into a new file. The syntax uses --pages and a range. The dot (.) refers to the primary input file.
qpdf input.pdf --pages . 3-7 -- output.pdfThis keeps only pages 3 through 7 and writes them to output.pdf.
Splitting with Pdfseparate (Poppler)
Poppler's pdfseparate is a lightweight utility that splits every page into a separate PDF. It is part of the poppler-utils package on Debian/Ubuntu and the poppler formula on macOS.
Basic Usage
The basic syntax is:
pdfseparate input.pdf page-%d.pdfThis creates page-1.pdf, page-2.pdf, and so on.
Set the First and Last Page
Limit the split to a range of pages using the -f (first) and -l (last) options. To split only pages 3 through 7:
pdfseparate -f 3 -l 7 input.pdf page-%d.pdfThis creates page-3.pdf through page-7.pdf.
pdfseparate does not support chunking into multi-page files. It only splits into individual pages.
Splitting with Pdftk Burst
pdftk's burst command splits a PDF into individual pages with a fixed naming convention.
Basic Burst
To split a PDF into separate page files, run:
pdftk input.pdf burstThis creates files named pg_0001.pdf, pg_0002.pdf, and so on, in the current directory. The numbering is zero-padded to four digits.
pdftk has no built-in option to split into chunks of a specific size. Combine burst with other tools, or use range extraction if your version supports it.
Handling Encrypted PDFs
If your PDF is password-protected, provide the password. qpdf accepts it with the --password option.
qpdf --password=YOUR_PASSWORD --split-pages input.pdf out-%d.pdfReplace YOUR_PASSWORD with the actual password. For pdfseparate, remove the encryption first using qpdf's --decrypt option. pdftk has an input_pw option, but the exact syntax depends on the version. Check the tool's help if you encounter issues.
Batch Splitting and Scripting
Command-line tools work well in scripts. Loop over multiple PDFs and split them all at once.
Split All PDFs in a Folder
Use a simple shell loop with qpdf:
for file in *.pdf; do qpdf --split-pages "$file" "${file%.pdf}-%d.pdf" doneThis processes every PDF in the current directory, creating output files like document-1.pdf, document-2.pdf.
Extract the Same Pages from Many Files
Use a loop with qpdf's --pages option to extract an identical page range from multiple files:
for file in *.pdf; do qpdf "$file" --pages . 3-7 -- "${file%.pdf}-extract.pdf" doneThis creates document-extract.pdf containing pages 3 to 7 of each original file.
Make your scripts executable and test them on a copy of your data first.