Home / Alt manpages / pdfseparate(1)

  • pdfseparate(1)
  • User command
  • linux

Split a PDF into Verified One-Page Files with pdfseparate

pdfseparate turns one PDF into one file per selected page, named from a pattern you control. It uses Poppler 24.02.0, supplied by Ubuntu package poppler-utils version 24.02.0-1ubuntu9.9, and you finish with a quick check that each output really is a single page.

Allow about ten minutes. You need a readable, unencrypted PDF and a writable destination directory. The normal commands are unprivileged; do not use sudo to extract a document unless its input or destination genuinely requires elevated access.

1. Check the installed command

Confirm the binary and its local version before building a script around it:

$ command -v pdfseparate
/usr/bin/pdfseparate
$ pdfseparate -v
pdfseparate version 24.02.0
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
$ dpkg-query -W -f='${Package} ${Version}\n' poppler-utils
poppler-utils 24.02.0-1ubuntu9.9

Copyright lines and package revision may differ elsewhere. What matters is that the command exists and reports the Poppler version you intend to use.

2. Inspect the source and choose a safe destination

Before extraction, check the input is a PDF and find its page count. pdfinfo is a separate Poppler utility, so this check does not alter the document:

$ pdfinfo /path/to/input.pdf | grep -E '^(Pages|Encrypted):'
Pages:           19
Encrypted:       no

Stop if the file is encrypted: the pdfseparate manual says the PDF should not be encrypted, and this guide does not cover supplying a password or removing encryption.

  • Make a new output directory, or use an empty one. That avoids confusing newly extracted pages with older files.
  • Never reuse a path shared with important originals unless you have checked every name the pattern can produce; pdfseparate writes files directly, so an existing matching file can be replaced.
$ mkdir -p /path/to/extracted-pages
$ find /path/to/extracted-pages -maxdepth 1 -type f -print

3. Extract every page with a numbered pattern

The command takes two positional arguments: the source PDF and a destination pattern. The pattern must contain %d, or a printf-compatible variant, since pdfseparate substitutes the page number there:

$ pdfseparate /path/to/input.pdf /path/to/extracted-pages/page-%d.pdf

For a 19-page source, expect names page-1.pdf through page-19.pdf. There is normally no per-page progress report: a return to the shell prompt means the command finished, so verify the result rather than trusting the absence of an error.

Checkpoint

Count the outputs and inspect their names.

$ find /path/to/extracted-pages -maxdepth 1 -type f -name 'page-*.pdf' | sort -V | wc -l
19
$ find /path/to/extracted-pages -maxdepth 1 -type f -name 'page-*.pdf' -printf '%f\n' | sort -V | sed -n '1,3p;$p'
page-1.pdf
page-2.pdf
page-3.pdf
page-19.pdf

Replace the count with your own pdfinfo Pages: value. The count is a useful check, but it does not prove every output is valid, or that no stale file was already sitting there.

4. Extract only a page range

Use -f for the first page and -l for the last, both inclusive. This example extracts pages 4 to 6:

$ pdfseparate -f 4 -l 6 /path/to/input.pdf /path/to/extracted-pages/section-%d.pdf
$ find /path/to/extracted-pages -maxdepth 1 -type f -name 'section-*.pdf' -printf '%f\n' | sort -V
section-4.pdf
section-5.pdf
section-6.pdf

Page numbers are PDF page positions starting at 1, and the output number stays the source page number, which helps when files go back in order later. Omit -f and extraction starts at page 1; omit -l and it ends at the last page.

Do not infer a range from a printed document's labels. A PDF can have front matter, Roman-numbered pages, or labels that do not match its internal page positions. Establish the positions first with pdfinfo, a viewer, or a careful visual check.

5. Verify each extracted file

Each output should be an independent one-page PDF. Check a representative file with pdfinfo:

$ pdfinfo /path/to/extracted-pages/section-4.pdf | grep -E '^(Pages|Page size):'
Pages:           1
Page size:       609.714 x 789.041 pts

Then check every file in a batch. This loop prints a filename and its page count, and every count should be 1:

$ for file in /path/to/extracted-pages/section-*.pdf; do
>     printf '%s: ' "$file"
>     pdfinfo "$file" | awk -F: '/^Pages:/ {gsub(/[[:space:]]/, "", $2); print $2}'
> done
/path/to/extracted-pages/section-4.pdf: 1
/path/to/extracted-pages/section-5.pdf: 1
/path/to/extracted-pages/section-6.pdf: 1

Open a sample if visual content matters. A successful command and a one-page count do not tell you whether it is the page you meant to send or archive.

6. Recover from mistakes safely

pdfseparate keeps no job record and has no undo. If you selected the wrong range, leave the original PDF alone and extract again into a fresh directory or with a new prefix. If a failed run left an incomplete output, remove only that known output after checking its path:

$ test -f /path/to/extracted-pages/section-6.pdf && printf '%s\n' 'review before removing'
$ rm -- /path/to/extracted-pages/section-6.pdf

Warning

rm is irreversible. Never use a wildcard until you have listed the exact files it would match. To replace an existing extraction, rename the old directory as a backup and create a new one instead of mixing outputs from two runs.

Common traps

  • Input error. Usually a wrong path or missing read permission.
  • Encrypted source. Outside this workflow entirely.
  • Destination pattern missing %d. The required page numbering never gets supplied.

Check spelling, permissions and the pattern before reaching for elevated privileges.

Done means

  • Version checked: the installed Poppler version and source PDF were confirmed.
  • Source verified: readable, unencrypted, page count recorded.
  • Pattern safe: the destination pattern contains %d and does not collide with valuable files.
  • Every page extracted: one numbered, one-page PDF per requested source page.
  • Output checked: a sample or all outputs verified with pdfinfo, original PDF untouched.