Automatically create professional court bundles in seconds.
BunTool is a web-based application designed to streamline the creation of court bundles for the English legal system. It takes multiple PDF files and combines them into a single, professionally formatted bundle with automatic indexing, pagination, hyperlinks, and bookmarks.
🔗 Live Instance: buntool.co.uk
- 📄 PDF Merging - Combine multiple PDF files into a single document
- 📑 Automatic Indexing - Generate table of contents with customizable formatting
- 🔢 Smart Pagination - Add page numbers with multiple style options
- 🔗 Hyperlinks - Clickable index entries that jump to documents
- 🔖 Bookmarks - PDF outline/bookmarks for easy navigation
- 📅 Date Parsing - Automatically extract dates from filenames
- 🎨 Customizable Styling - Multiple font options for index and page numbers
- 📋 Section Markers - Organize documents into logical sections
- 📄 Coversheet Support - Optional custom cover page
- 🔐 Confidential Marking - Add confidential labels to bundles
- 📊 Multiple Date Formats - UK/US date formatting options
- 🔢 Roman Numerals - Optional roman numeral pagination for front matter
- 📦 ZIP Export - Download bundle with all source files and editable index
- 📝 DOCX Index - Separate Word document index for editing
- ✅ Complies with English Court bundle requirements
- ✅ Suitable for various legal and professional applications
- ✅ Maintains document integrity and metadata
BunTool automates the tedious process of creating court bundles by:
- Accepting multiple PDF files via drag-and-drop or file selection
- Parsing filenames to extract titles and dates automatically
- Generating a professional table of contents with customizable formatting
- Merging all documents with proper pagination starting from page 1
- Adding clickable hyperlinks from the index to each document
- Creating PDF bookmarks for easy navigation
- Outputting a single, court-ready PDF bundle
The result is a professional bundle that would typically take hours to create manually, completed in seconds.
- Legal Professionals - Court bundles, hearing bundles, trial bundles
- Solicitors - Case file compilation and organization
- Barristers - Brief preparation and document bundling
- Corporate Legal - Document compilation for litigation
- General Use - Any scenario requiring organized PDF compilation
- Python 3.8 or higher
- pip (Python package manager)
- Virtual environment support
-
Clone the repository
git clone https://github.com/TrisSherliker/buntool.git cd buntool -
Create a virtual environment
python3 -m venv .venv
-
Activate the virtual environment
On macOS/Linux:
source .venv/bin/activateOn Windows:
.venv\Scripts\activate
-
Install required packages
pip install -r requirements.txt
-
Install Charter fonts (Required for traditional font option)
The Charter font files need to be copied to ReportLab's fonts directory:
On macOS/Linux:
cp static/Charter*.ttf .venv/lib/python*/site-packages/reportlab/fonts/
On Windows:
copy static\Charter*.ttf .venv\Lib\site-packages\reportlab\fonts\
-
Configure environment variables (Recommended for production)
export SECRET_KEY="your-secret-key-here" export FLASK_ENV="production"
-
Start the server
python app.py
-
Access the application
Open your browser and navigate to:
http://127.0.0.1:7001
SECRET_KEY- Flask secret key for session security (required for production)FLASK_ENV- Set toproductionfor production deploymentMAX_CONTENT_LENGTH- Maximum upload size (default: 100MB)
Edit app.py to customize:
- Port number (default: 7001)
- Host address (default: 0.0.0.0)
- Upload limits
- Temporary file locations
-
Enter Bundle Details (Step 1)
- Bundle title (e.g., "Bundle A: Proceedings")
- Case name (e.g., "Smith v Jones")
- Claim number (optional)
-
Upload PDF Files (Step 2)
- Drag and drop PDFs or click to select
- Files are automatically analyzed for dates and titles
- Reorder files by dragging rows
- Edit titles and dates as needed
- Add section markers to organize documents
-
Choose Options (Step 3)
- Index Options:
- Font style (Sans, Serif, Mono, Traditional)
- Optional coversheet
- Date format
- Confidential marking
- Page Numbering Options:
- Footer font style
- Alignment (left, center, right)
- Numbering style (Page 1, 1 of 100, etc.)
- Optional prefix text
- Roman numerals for front matter
- Index Options:
-
Create Bundle (Step 4)
- Click "CREATE BUNDLE"
- Download PDF bundle
- Optionally download ZIP with all files
- Filename Conventions: Include dates in filenames (YYYY-MM-DD or DD-MM-YYYY) for automatic parsing
- File Organization: Upload files in the order you want them to appear
- Section Markers: Use sections to group related documents
- Title Editing: Review auto-generated titles and adjust as needed
- Date Verification: Check that dates are correctly parsed from filenames
- Backend: Flask (Python web framework)
- PDF Processing: pypdf, pikepdf, pdfplumber
- PDF Generation: ReportLab
- Document Processing: python-docx
- Server: Waitress (production WSGI server)
- Frontend: Vanilla JavaScript, HTML5, CSS3
buntool/
├── app.py # Flask application and routes
├── bundle.py # Core PDF processing logic
├── makedocxindex.py # DOCX index generation
├── requirements.txt # Python dependencies
├── static/ # Static assets (CSS, JS, fonts, images)
├── templates/ # HTML templates
├── licenses/ # Third-party licenses
└── README.md # This file
- User uploads files via web interface
- Files stored in temporary directory with session ID
- CSV index generated from user input
- PDFs merged and processed by bundle.py
- Index, pagination, hyperlinks, and bookmarks added
- Final bundle saved to output directory
- Temporary files cleaned up
- User downloads completed bundle
SECURITY_REVIEW.md file for detailed security analysis and recommendations.
- Files are processed in isolated temporary directories
- Automatic cleanup of temporary files
- File type validation (PDF only)
- Filename sanitization
- Session-based isolation
Before deploying to production, implement:
- Flask secret key configuration
- CSRF protection
- Rate limiting
- Input validation
- Security headers
- HTTPS/TLS encryption
- Regular security updates
See SECURITY_REVIEW.md for complete security recommendations.
- File Processing: All files are processed locally on the server
- Temporary Storage: Files stored temporarily during processing
- Automatic Deletion: Files deleted after bundle creation
- Logging: Minimal logging of filenames and metadata for debugging
- No Cloud Storage: Files are not uploaded to external services (S3 code is commented out)
For self-hosted instances, you control all data handling and retention policies.
Fonts not displaying correctly
- Ensure Charter fonts are copied to ReportLab's fonts directory
- Check file permissions on font files
Upload fails
- Check file size limits (default 100MB total)
- Verify PDF files are not corrupted
- Ensure sufficient disk space in temp directory
Server won't start
- Check if port 7001 is already in use
- Verify all dependencies are installed
- Check Python version (3.8+ required)
Bundle creation fails
- Check server logs in
logs/directory - Verify all uploaded PDFs are valid
- Ensure sufficient memory for large bundles
export FLASK_ENV=development
python app.pyThe application includes extensive logging for debugging. Logs are stored in:
- Development:
logs/directory - Production:
/tmp/buntool/logs/
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
See the TODO section in bundle.py for planned features:
- Enhanced error handling
- Input validation improvements
- Page number offset capability
- State reload from ZIP import
- Additional customization options
- Flask 3.1.0 - Web framework
- Werkzeug 3.1.3 - WSGI utilities
- waitress 3.0.2 - Production WSGI server
- pypdf 5.1.0 - PDF manipulation
- pikepdf 9.5.1 - PDF processing
- pdfplumber 0.11.5 - PDF text extraction
- reportlab 4.3.0 - PDF generation
- python-docx 1.1.2 - DOCX generation
See requirements.txt for complete list and licenses/ directory for third-party licenses.
Copyright © Tristan Sherliker and contributors to BunTool
Licensed under the Mozilla Public License, version 2.0 (MPL-2.0).
See LICENSE.md for full license text.
- Charter font for legal document styling
- ReportLab for PDF generation capabilities
- The Python PDF processing community
- Issues: Report bugs via GitHub Issues
- Email: tris@sherliker.net
- Website: buntool.co.uk
This software is provided "as is" without warranty of any kind. While designed for legal document preparation, users should verify all output meets their specific requirements and court rules. Always review generated bundles before filing or submission.
