Skip to main content

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 - PyMuPDF
  • docx - python-docx
  • pptx - python-pptx
  • html - 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 .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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docrouter-0.2.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docrouter-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file docrouter-0.2.0.tar.gz.

File metadata

  • Download URL: docrouter-0.2.0.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

Hashes for docrouter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fa209f47ec4c982a66412be31b3704b331e192e875f6ac2c500f81f187a0857d
MD5 d6162c61be4216c9e97f1945d5561faf
BLAKE2b-256 1898c03330d7addbd85cd9873ad452c5626c13bb4ad01b585bd1664f51ba2e02

See more details on using hashes here.

File details

Details for the file docrouter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: docrouter-0.2.0-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

Hashes for docrouter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c33be89d9cb1d4262aaa1cf59e07743ba6ee37e17e346930dbdb3bc7e26d8f0c
MD5 8c55993434c24695d386d99453402089
BLAKE2b-256 266b960ba18e2f147fac42819273746648c2445ec752f85dff2418e6e070ee5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page