Command line tool that splits a PDF file by its table of contents. Written in Python.
Install the project and its development tools with uv:
uv syncRun the tests with make test, and format the Python files with make format.
uv run pdf-toc-splitter <OPTIONS> file.pdfThere are six options:
--dry-run: Simulates the split. Prints the filenames, but does not create any files. Useful when checking if the options have been set correctly.--depth INTEGER: The level of depth at which the splits will occur. See figure 1 for a visual explanation. Default value is set to 1.--max-filename-length INTEGERIf set to anything but 0 (the default), created file names will not exceed this length.--regex TEXT: Selects outline items that match a RegEx pattern. For example--regex "^Chapter"will only select outline items that start with the stringChapter.--overlap: Overlaps split points. By default, if Chapter 1 starts at page 1 and Chapter 2 starts at page 10,Chapter 1.pdfwill contain pages 1–9, andChapter 2.pdfwill contain pages 10–.... By including the--overlapoption,Chapter 1.pdfwill now contain pages 1–10, andChapter 2.pdfwill contain pages 10..., etc. This is a useful option, if a section can start in the middle of a page.--prefix TEXT: Adds a prefix to the output filenames. Supports the{n}placeholder for an n-th item index. For example,--prefix "CLRS_{n}_"results inCLRS_1_<name>.pdf.
Licensed under AGPL.

