Unified document interrogation: retrieve, screenshot, search
Project description
docrouter
A swiss army knife for document handling in LLM agents and apps.
docrouter provides a unified API to extract text, search content, and render pages across multiple document formats. It's designed for rapid prototyping - when you need to quickly build an agent that can work with PDFs, Word docs, PowerPoints, and more without wrestling with a dozen different libraries.
What this is
- A single interface for text extraction and search across PDF, DOCX, PPTX, HTML, Markdown, and plain text
- Built with LLM tool-calling in mind (includes a ready-to-use tool API with document registry)
- Zero core dependencies - install only what you need
- Good enough extraction for most prototyping and simple production use cases
What this isn't
This library doesn't compete with state-of-the-art (often paid, API-based) solutions for individual file types. If you need production-grade PDF extraction with perfect table parsing, OCR, or layout analysis, check out specialized tools like Datalab - they're excellent at what they do.
docrouter is for when you need to get something working quickly across multiple formats without overthinking it.
Installation
pip install docrouter[all] # all formats
pip install docrouter[pdf] # PDF only
pip install docrouter # txt/md only (no deps)
Optional dependencies by format:
pdf- PyMuPDFdocx- python-docxpptx- python-pptxhtml- BeautifulSoup4, lxml
Quick start
from docrouter import open_document
doc = open_document("report.pdf")
doc.info() # metadata: pages, title, etc.
doc.get_text() # full document text
doc.search("revenue") # find text with context
doc.render_page(0) # screenshot page as PNG (PDF only)
Tool API (for LLM agents)
The tool API maintains a document registry, making it easy to integrate with function-calling LLMs:
from docrouter.tools import (
open_document_tool,
search_tool,
get_text_tool,
close_document_tool
)
# Open and register a document
result = open_document_tool("quarterly_report.pdf")
doc_id = result["document_id"]
# Search across the document
hits = search_tool(doc_id, "operating income", max_hits=5)
# Get full text or specific pages
text = get_text_tool(doc_id)
# Clean up when done
close_document_tool(doc_id)
Supported formats
| Format | Extensions | Unit type | Features |
|---|---|---|---|
.pdf |
page | text, search, render | |
| Word | .docx |
section | text, search, tables |
| PowerPoint | .pptx |
slide | text, search, tables, notes |
| HTML | .html, .htm |
section | text, search |
| Markdown | .md |
chunk | text, search |
| Plain text | .txt, .csv, .json, etc. |
chunk | text, search |
| Code | .py, .js, .ts, etc. |
chunk | text, search |
| Images | .png, .jpg, etc. |
- | metadata only |
Contributing
Contributions are welcome! If you'd like to extend docrouter with new formats, better extraction for existing ones, or other improvements, please open an issue or PR.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docrouter-0.2.1.tar.gz.
File metadata
- Download URL: docrouter-0.2.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
861cbc2651983c085a2c0af70e1ed8d7ef00996f74be68006b7be6d99836a07b
|
|
| MD5 |
78c943584c87255fb2ee31b16d0eeffd
|
|
| BLAKE2b-256 |
e90b3bb397f43fcd7ed06b9443ea2916f3985aefb7317076b3566d5e9df94300
|
File details
Details for the file docrouter-0.2.1-py3-none-any.whl.
File metadata
- Download URL: docrouter-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d44f73972fb7c418573d825c5cc66932c1107cd0a4eb22f4ed9ba8c8d5a91be
|
|
| MD5 |
958534c9d8cc708cf6f3da6f049181ba
|
|
| BLAKE2b-256 |
6cad4f6b56bce3433c919016ffb0b147526e3fa0d9c007860df2ef178039a317
|