PDFOutliner is a Python-based tool that extracts clean, hierarchical outlines from PDF documents.
By analyzing document structure, it generates a navigable JSON representation of headings (H1–H3) and their relationships, enabling advanced navigation, search, and content analysis.
- Analyzes font size, weight, and positioning to detect headings
- Identifies hierarchical relationships between headings
- Preserves original document organization
- Works with inconsistently formatted PDFs
- Supports multi-page documents
- Language-agnostic text analysis
- Standards-compliant JSON output
- Preserves heading hierarchy
- Includes page numbers for easy navigation
- Python 3.10 or later
- pip (Python package manager)
- Docker (optional, for containerized usage)
# Clone the repository
git clone https://github.com/Dhwanitisshah/Structured-PDF-Outline-Extractor.git
cd Structured-PDF-Outline-Extractor
# Install dependencies
pip install -r requirements.txt# Build the Docker image
docker build -t pdfoutliner .
# Run the container
docker run -v "$(pwd)/input:/app/input" -v "$(pwd)/output:/app/output" pdfoutliner# Place your PDF in the input folder
mkdir -p input output
cp your_document.pdf input/
# Run the script
python pdf_outliner.py
# Output will be in the 'output' folder as JSONdocker run -v "$(pwd)/input:/app/input" -v "$(pwd)/output:/app/output" pdfoutlinerInput
- Location:
/app/input - Format: PDF files (
*.pdf)
Output
- Location:
/app/output - Format: JSON (same name as input PDF)
Example Output
{
"title": "Sample Document",
"headings": [
{
"text": "Introduction",
"level": 1,
"page": 1,
"children": [
{
"text": "Background",
"level": 2,
"page": 1
}
]
}
]
}Architecture – Hybrid approach combining:
- Native PDF Structure Analysis – Extracts built-in outlines when available
- Heuristic Font Analysis – Detects headings based on font size, weight, and style
- Position-Based Context – Uses text positioning to infer hierarchy
Dependencies
- PyMuPDF – Layout-aware text extraction
- pdfplumber – Font metadata analysis
- Python Standard Libraries –
re,collections,json,logging
Structured-PDF-Outline-Extractor/
│── input/ # PDF files to process
│── output/ # Extracted JSON outlines
│── pdf_outliner.py # Main script
│── requirements.txt # Python dependencies
│── Dockerfile # Docker build configuration
│── README.md # Project documentation
- 🌐 Enhanced Language Support for non-Latin scripts
- 🤖 NLP Integration for better heading context analysis
- 📊 Confidence Scoring for extraction accuracy
- 🌍 Web API for remote PDF processing
- 📦 Batch Processing for multiple files
This project is licensed under the MIT License – see the LICENSE file for details.