Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pdf-chapter-splitter

A command-line tool that splits a book PDF into smaller PDFs sized for uploading as separate sources to NotebookLM (or any tool with per-file size/count limits). It uses the PDF's own outline (bookmarks) to split at chapter boundaries where possible.

Install

pip install pypdf --break-system-packages

Usage

python split_book.py <input.pdf> [--level N] [--target-pages N] [--fixed N] [--out DIR] [--list]

Modes

Outline mode (default) — split at each chapter/bookmark found at a given outline depth:

python split_book.py book.pdf --level 1

Grouping mode — detect chapters from the outline, then merge consecutive chapters into larger files until each is at least --target-pages pages (never splits a chapter across files):

python split_book.py book.pdf --level 2 --target-pages 60

Fixed-size mode — ignore the outline entirely and split every N pages:

python split_book.py book.pdf --fixed 50

Recommended workflow: --list first

Always start with --list to preview the plan (chapter titles, page ranges, page counts) without writing any files:

python split_book.py book.pdf --level 1 --list

Outlines commonly have multiple usable depths — e.g. --level 1 might show only a handful of huge "Part" entries, while --level 2 reveals the real ~30-40 chapters. Check a couple of --level values with --list before committing to a real split. If the PDF has no usable outline at any level, fall back to --fixed N or pair a shallow outline level with --target-pages N.

Output layout

Files are written to <out>/<input-stem>/, e.g.:

chunks/
  resnick-halliday/
    01_Chapter_1_Measurement.pdf
    02_Chapter_2_Motion_Along_a_Straight_Line.pdf
    ...

This per-book subfolder (under a shared --out base directory, default ./chunks) lets you split multiple books into the same output location without filename collisions.

Tests

python -m pytest tests/

About

CLI tool to split a PDF into per-chapter or grouped chunks using its outline/bookmarks, with page-count and fixed-split fallbacks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages