Super Document Processor
A high-fidelity, multi-format document parsing and chunking engine tailored for Retrieval-Augmented Generation (RAG) pipelines. It extracts structured text, preserves tables, optionally transcribes embedded charts and images with Vision LLMs, and outputs boundary-aligned chunks.
Available as a Python library, CLI tool, and FastAPI microservice (with Docker support).
Supported Formats
| Category | Formats | Features Extracted |
|---|---|---|
| Documents | .pdf, .docx |
Headings, paragraphs, markdown/HTML tables, hyperlinks, embedded images |
| Presentations | .pptx |
Slide text, shapes, notes, multi-table separation, smart-art, charts |
| Emails | .msg |
Headers (From, To, Subject, Date) and formatted email body |
| Images | .jpg, .jpeg, .png, .jfif |
Full VLM vision analysis and table transcription |
| Code & Text | .txt, .md, .json, .csv, .py, .js, .ts, .html, etc. |
Natural paragraph and token-bounded chunking |
Quickstart
1. Install via PyPI
pip install super-document-processor
2. Or Local Clone
git clone https://github.com/Cinderfox/Super-Document-Processor.git
cd Super-Document-Processor
python -m venv .venv
source .venv/bin/activate # On Windows: .\.venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
3. Docker
# Using Docker CLI:
docker run -d --name doc-processor -p 8000:8000 -v ${PWD}/data:/data cinderfox/super-document-processor:latest
# Or using Docker Compose:
docker compose up -d
1. Python Library Usage
from super_document_processor import process_file
# 1. Standard text & table extraction (zero LLM calls, ultra-fast)
chunks = process_file("annual_report.pdf")
# 2. Extract with Vision LLM (describes embedded charts, diagrams, and photos)
# (api_key and base_url can be passed directly or read from OPENAI_API_KEY / OPENAI_BASE_URL env vars)
chunks_with_vision = process_file(
file_path="pitch_deck.pptx",
process_images=True,
model="google-gemini-3-flash", # e.g. "gpt-4o", "google-gemini-3-flash", etc.
api_key="your-api-key", # optional: falls back to env var
base_url="https://api.openai.com/v1" # optional: falls back to env var
)
for chunk in chunks:
print(f"--- Chunk {chunk['chunkIndex']} ({chunk['filename']}) ---")
print(chunk["content"])
Chunk Data Structure
[
{
"content": "==================== Slide 1 ====================\nSlide Text:\n- Performance Scorecard...",
"chunkIndex": 1,
"filename": "pitch_deck.pptx"
}
]
Direct Chunker Access & Default Limits
Text-based document processors (.docx, .msg, .txt etc) use ChunkCollector for token-safe output partitioning:
- Default Max Size:
6,000characters per chunk - Default Overlap:
0characters (zero duplicated text across chunks)
from super_document_processor.utils.chunker import collector, chunk_text
# Using standalone utility with custom values:
chunks = chunk_text(text="Your long text...", chunk_size=6000, overlap=200)
# Or collecting and retrieving chunked texts:
collector.add("First section text...")
chunks = collector.get_chunked_texts(max_size=6000, overlap=200)
collector.clear()
PPTX Slide Rendering & Image Conversion
Export PowerPoint slides directly to SVGs or PNGs:
from super_document_processor import convert_pptx, create_pptx_render_zip
# 1. Convert all slides to SVGs (returns list of clean SVG strings)
res = convert_pptx("presentation.pptx", format="svg")
for s in res["slides"]:
print(f"Slide {s['slide']}: {s['svg'][:80]}...")
# 2. Convert specific slide to high-res PNG bytes
res_png = convert_pptx("presentation.pptx", format="png", slide=1, scale=2.0)
with open("slide_1.png", "wb") as f:
f.write(res_png["raw_bytes"])
# 3. Create a downloadable ZIP containing all rendered slides
zip_bytes = create_pptx_render_zip("presentation.pptx", format="png")
with open("presentation_pngs.zip", "wb") as f:
f.write(zip_bytes)
2. CLI Usage
# Basic extraction to terminal (stdout)
python main.py document.pdf
# Save raw JSON chunks to a file
python main.py report.docx --json -o output.json
# Process embedded images using a Vision Model
python main.py slides.pptx --process-images --model google-gemini-3-flash --json -o output.json
# Convert all PPTX slides to clean SVG files in a directory
python main.py slides.pptx --convert-pptx --format svg -o ./output_svgs
# Convert specific slide to PNG
python main.py slides.pptx --convert-pptx --format png --slide 1 -o slide_1.png
# Convert PPTX and package all slides into a ZIP archive
python main.py slides.pptx --convert-pptx --format png --as-zip -o slides.zip
# Start the REST API server
python main.py --serve --port 8000
| Flag | Short | Default | Description |
|---|---|---|---|
file |
None | Path to document or image file | |
--json |
False |
Output as raw JSON chunks or JSON slide array | |
--output |
-o |
stdout |
Destination file path or directory for output |
--convert-pptx |
-c |
False |
Convert PPTX slides to SVG or PNG images |
--format |
-f |
svg |
Target conversion format (svg or png) |
--slide |
All | Specific 1-based slide index to convert | |
--scale |
2.0 |
Resolution scale factor for PPTX slide rendering (PNG image only) | |
--as-zip |
False |
Bundle all converted slides into a single .zip file |
|
--process-images |
False |
Enable AI vision processing for images/tables | |
--model |
-m |
None | Vision model name (required if --process-images is set) |
--api-key |
None | OpenAI/VLM API key (falls back to OPENAI_API_KEY env var) |
|
--base-url |
None | OpenAI/VLM Base URL (falls back to OPENAI_BASE_URL env var) |
|
--serve |
-s |
False |
Start the FastAPI HTTP microservice |
--port |
-p |
8000 |
Server listening port |
3. REST API Microservice
Start the server with python main.py --serve --port 8000 or via Docker.
- Swagger Docs:
http://localhost:8000/docs - Health Check:
http://localhost:8000/health
1. Document Parsing & Chunking: POST /process
Accepts either a file upload (multipart/form-data) or a local/volume file path (application/json). Providing both or neither returns an HTTP 400 error.
Parameters
Can be passed as Query Parameters, Multipart Form fields, or JSON Body fields:
| Parameter | Type | Default | Description |
|---|---|---|---|
file |
file | None | Document binary file (Multipart Form). |
file_path |
string | None | Path to local document or container mounted volume file (JSON body / Form). |
process_images |
boolean | false |
Enable Vision LLM parsing for embedded images, charts, and diagrams. |
model |
string | None | Vision model name (required when process_images=true, e.g. gpt-4o, google-gemini-3-flash). |
api_key |
string | None | Optional per-request API key (falls back to OPENAI_API_KEY environment variable). |
base_url |
string | None | Optional per-request base URL (falls back to OPENAI_BASE_URL environment variable). |
Option A: File Upload (Multipart Form)
# Basic upload
curl -X POST "http://localhost:8000/process" \
-F "file=@/path/to/contract.pdf"
# With Vision LLM processing (api_key and base_url can be sent via form or query params)
curl -X POST "http://localhost:8000/process" \
-F "file=@/path/to/presentation.pptx" \
-F "process_images=true" \
-F "model=google-gemini-3-flash" \
-F "api_key=your-key" \
-F "base_url=https://api.openai.com/v1"
Option B: Local File Path or Mounted Volume Path (JSON)
# Running locally:
curl -X POST "http://localhost:8000/process" \
-H "Content-Type: application/json" \
-d '{"file_path": "./test_docs/report.pdf"}'
# With Vision LLM and custom base_url / api_key in request body:
curl -X POST "http://localhost:8000/process" \
-H "Content-Type: application/json" \
-d '{
"file_path": "/data/report.pdf",
"process_images": true,
"model": "gpt-4o",
"api_key": "your-key",
"base_url": "https://api.openai.com/v1"
}'
2. PPTX to SVG / PNG Conversion: POST /convert/pptx
Renders PowerPoint slides into SVG or PNG images with evaluation watermarks stripped.
Parameters
Can be passed as Query Parameters (e.g. ?slide=1&format=png), Multipart Form fields, or JSON Body fields:
| Parameter | Type | Default | Description |
|---|---|---|---|
slide |
integer | None (all) | Specific 1-based slide index to render. If provided, returns the raw image stream directly. |
format |
string | "svg" |
Output format: "svg" or "png" (also accepts "img", "image"). |
scale |
float | 2.0 |
Resolution scale factor (PNG image only). |
as_zip |
boolean | false |
When rendering all slides, bundles them into a downloadable .zip archive. |
response_type |
string | auto | Set to "json" to return an array of slides (content for SVG or png_base64). |
Stream Single Slide Directly as Image (image/svg+xml or image/png)
Ideal for embedding directly in <img> tags or displaying in browsers:
# Get Slide 1 as direct SVG
curl -X POST "http://localhost:8000/convert/pptx?slide=1&format=svg" \
-F "file=@presentation.pptx" > slide_1.svg
# Get Slide 2 as direct high-res PNG
curl -X POST "http://localhost:8000/convert/pptx?slide=2&format=png&scale=2.0" \
-F "file=@presentation.pptx" > slide_2.png
Download All Slides as a ZIP Archive
curl -X POST "http://localhost:8000/convert/pptx?format=png&as_zip=true" \
-F "file=@presentation.pptx" -o presentation_slides.zip
Convert Mounted Volume Path via JSON Body
# Convert specific slide to PNG
curl -X POST "http://localhost:8000/convert/pptx" \
-H "Content-Type: application/json" \
-d '{"file_path": "/data/presentation.pptx", "slide": 1, "format": "png"}' -o slide_1.png
# Convert all slides to SVG
curl -X POST "http://localhost:8000/convert/pptx" \
-H "Content-Type: application/json" \
-d '{"file_path": "/data/presentation.pptx", "format": "svg"}'
Python Client Example
import requests
url = "http://localhost:8000/convert/pptx"
# 1. Download Slide 1 directly as image
with open("pitch_deck.pptx", "rb") as f:
resp = requests.post(url, files={"file": f}, params={"slide": 1, "format": "png"})
with open("slide_1.png", "wb") as out:
out.write(resp.content)
# 2. Get all slides as JSON payload (contains SVGs or base64 PNGs)
with open("pitch_deck.pptx", "rb") as f:
resp = requests.post(url, files={"file": f}, params={"format": "svg", "response_type": "json"})
data = resp.json()
print(f"Rendered {data['total_slides']} slides.")
3. Async Processing: POST /process-async & GET /jobs/{job_id}
For large files or heavy multimodal extraction, submit jobs asynchronously to prevent client gateway timeouts. No Redis required (backed by persistent /data/jobs storage).
Parameters (POST /process-async)
Can be passed as Query Parameters or Multipart Form fields:
| Parameter | Type | Default | Description |
|---|---|---|---|
file |
file | Required | Document binary file to process in the background. |
process_images |
boolean | false |
Enable Vision LLM processing of embedded images/tables. |
model |
string | None | Vision model name (required if process_images=true). |
api_key |
string | None | Optional per-request API key (falls back to OPENAI_API_KEY env var). |
base_url |
string | None | Optional per-request base URL (falls back to OPENAI_BASE_URL env var). |
1. Submit Job (POST /process-async)
curl -X POST "http://localhost:8000/process-async" \
-F "file=@large_document.pdf"
{
"job_id": "e8d7a12b-34c5-4f67-8901-abcdef123456",
"filename": "large_document.pdf",
"status": "processing",
"poll_url": "/jobs/e8d7a12b-34c5-4f67-8901-abcdef123456"
}
2. Poll Status & Fetch Result (GET /jobs/{job_id})
# Standard idempotent poll (retains result for safe retries up to JOB_RETENTION_SECONDS)
curl "http://localhost:8000/jobs/e8d7a12b-34c5-4f67-8901-abcdef123456"
# Or explicitly delete from disk immediately upon retrieval:
curl "http://localhost:8000/jobs/e8d7a12b-34c5-4f67-8901-abcdef123456?consume=true"
- In Progress:
{"status": "processing", "progress": 0} - Completed: Returns the full JSON payload (
"status": "completed",total_chunks,chunks). - Retention & Auto-Purge: Results are preserved for idempotent retries and automatically garbage collected after
JOB_RETENTION_SECONDS(default: 15 minutes / 900s).
4. Docker Deployment
The container image includes all rendering dependencies (libicu, ca-certificates, etc.).
Run as an API Server
# Port 8000 exposed, local ./data folder mounted to /data in container
docker run -d \
--name doc-processor \
-p 8000:8000 \
--env-file .env \
-v ${PWD}/data:/data \
cinderfox/super-document-processor:latest
Run as One-Off CLI Tool & Save Output to Host
Files created inside Docker default to the container's isolated layer. To save the output JSON directly on your host machine, use either Volume Mounting or Shell Redirection:
# Method 1: Mount folder and write with -o (appears in your host folder)
docker run --rm -v ${PWD}:/data cinderfox/super-document-processor:latest \
python main.py /data/report.pdf --json -o /data/output.json
# Method 2: Stream stdout directly to host file (works with docker run or docker exec)
docker run --rm -v ${PWD}:/data cinderfox/super-document-processor:latest \
python main.py /data/report.pdf --json > output.json
# Method 3: Run against an already active container
docker exec doc-processor python main.py /data/report.pdf --json > output.json
Docker Compose
services:
doc-processor:
image: cinderfox/super-document-processor:latest
container_name: doc-processor
restart: unless-stopped
ports:
- "8000:8000"
env_file:
- .env
volumes:
- ./data:/data
docker compose up -d
5. Configuration & Environment Variables
All settings can be configured via environment variables or a .env file in the root directory:
| Variable | Default | Description |
|---|---|---|
PORT |
8000 |
HTTP port when running in server mode |
MAX_FILE_SIZE_MB |
None (unlimited) | Optional max upload file limit (MB). Returns 413 Payload Too Large if exceeded |
MAX_CONCURRENT_JOBS |
4 |
Max parallel background async jobs before queueing |
JOB_RETENTION_SECONDS |
900 |
Time-to-live (seconds) for completed/failed async job files on disk |
JOBS_DIR |
/data/jobs (or ./data/jobs) |
Storage directory for asynchronous background job results |
MAX_WORKERS |
3 |
Max concurrent worker threads for slide rendering, image extraction, and VLM calls |
OPENAI_API_KEY |
None | Optional default API key for Vision LLM extraction (can also be passed per-request) |
OPENAI_BASE_URL |
None | Optional default Gateway URL (e.g. https://api.openai.com/v1, LiteLLM, Ollama, etc.) |
License
Metadata
Release files for super-document-processor 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| super_document_processor-1.0.2.tar.gz | 84.4 kB | Without provenance | Details for super_document_processor-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| super_document_processor-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for super_document_processor-1.0.2-py3-none-any.whl |
Total release size: 170.0 kB
Release files / super_document_processor-1.0.2.tar.gz
| Download URL | super_document_processor-1.0.2.tar.gz |
|---|---|
| Size | 84.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a144080de2de2093c5f725eddfb54ce9d494d2a51ad12f8f0bbe97700cbd9e5
|
|
BLAKE2b-256 checksum How to use checksums |
7dc7e8a371fdbe21c84c0486dba5893cf4290c32fab28083f895b68fbb1df26a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.4
|
Release files / super_document_processor-1.0.2-py3-none-any.whl
| Download URL | super_document_processor-1.0.2-py3-none-any.whl |
|---|---|
| Size | 85.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a5bcb7084276e764f69b97da9d3f2405476d6b6caea4eab44b592a2c17b3410
|
|
BLAKE2b-256 checksum How to use checksums |
6cbd89de8f132f49d9dc1da164c6fcb3f12f6510120ae7edbf87f8ea3860fcda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.4
|
Security for super-document-processor 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.