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.
pip install pypdf --break-system-packages
python split_book.py <input.pdf> [--level N] [--target-pages N] [--fixed N] [--out DIR] [--list]
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
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.
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.
python -m pytest tests/