pdfblah.com

← All guides

Split a PDF by what's on its pages

The accounting system exported all 73 invoices as one 200-page PDF. Splitting by page count is useless when invoices run 1-4 pages each. split --at starts a new file wherever a pattern appears, and names each file from the page itself.

One file per invoice, named correctly

pip install pdfblah

pdfblah split all.pdf -o invoices/ --at "Invoice #(\S+)" --name "{1}.pdf"
split into 4 file(s) in invoices/
  front.pdf     (pages 1-1)
  ACME-100.pdf  (pages 2-3)
  BETA-7.pdf    (pages 4-4)
  ACME-101.pdf  (pages 5-6)

And for book scans: cut the spreads apart

Scanned a book two pages at a time? Every PDF page holds a left and a right page. --spread cuts them apart:

pdfblah split book.pdf --spread pages.pdf
pdfblah split manga.pdf --spread pages.pdf --order rl   # right-to-left books

The cut is lossless: each half is a crop window over the original content, exactly like a viewer zooming into one page, so nothing is re-rendered and the file stays crisp. Landscape spreads split left/right; portrait ones split top/bottom.

Tips