Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

PDF Splitter by Index

This Python script splits a PDF into multiple smaller PDFs based on an index.
The index defines the title and start page of each section.
The script automatically calculates the end page for each section using the next section's start page.


Requirements

  • Python 3.8+

Setup

Use the provided setup script to automatically create a virtual environment and install dependencies:

chmod +x setup.sh
./setup.sh

This will:

  • Create a Python virtual environment (.venv)
  • Activate the virtual environment
  • Upgrade pip to the latest version
  • Install all required dependencies from requirements.txt

After setup, activate the virtual environment with:

source .venv/bin/activate

Usage

  1. Put your PDF file at the root directory (named as document.pdf)

  2. Run the script with:

python main.py

It will:

  • Read document.pdf

  • Read index.json

  • Create one PDF per section inside the output/ directory

Files

  • split_pdf.py → the main script
  • setup.sh → automated setup script for virtual environment and dependencies
  • requirements.txt → Python dependencies
  • logo.svg → project logo
  • index.json → defines the index
  • document.pdf → the original PDF to split
  • output/ → folder where the split PDFs will be stored

Notes

  • Filenames are generated from the section titles (spaces replaced with _).

  • The last section automatically goes until the last page of the PDF.

  • Works with any PDF and any custom index JSON.

About

Split PDFs following an index

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /