Skip to content

sweetbrulee/split-pdf

Repository files navigation

PDF Splitting Tools

This repository contains tools for splitting PDF files based on their document outlines (bookmarks). It offers both a web-based UI and a Python command-line interface (CLI).

1. Web Application (Vue.js)

A user-friendly web interface built with Vue.js, TypeScript, and Vite that allows you to split PDFs directly in your browser.

Features:

  • Upload a PDF file.
  • Preview the document outline.
  • Specify a maximum depth for splitting chapters/sections.
  • Option to add numerical prefixes to the split file names.
  • Download the split PDF files as a ZIP archive.
  • All processing is done client-side; your files are not uploaded to a server.

Recommended IDE Setup

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone vue-tsc fails to build due to upstream errors, check out the official documentation for more solutions.

Project Setup and Usage

  1. Install Dependencies:

    pnpm install

    (Or npm install / yarn install if you prefer, though a pnpm-lock.yaml is present)

  2. Run Development Server:

    pnpm dev

    This will start the Vite development server, typically at http://localhost:5173.

  3. Build for Production:

    pnpm build

    This will compile and minify the application for production deployment into the dist directory.

  4. Preview Production Build:

    pnpm preview

    This command serves the contents of the dist directory locally.

2. Python Command-Line Tool

A Python script for splitting PDFs, useful for scripting or server-side operations.

Features:

  • Splits PDF files based on outline (bookmark) hierarchy.
  • Allows specifying a maximum depth for splitting.

Usage and Setup

For detailed instructions on how to set up and use the Python CLI tool, please refer to its dedicated README file: Python PDF Splitter CLI README


This project was initially based on a standard Vue 3 + TypeScript + Vite template. The web application uses pdfjs-dist for reading PDF structures and pdf-lib for creating and manipulating PDF documents in the browser.

About

Split PDF according to the outline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published