Skip to content

doc-router

Rust tool that asks Jev which PDF pages genuinely need OCR, extracting text pages locally and sending only the rest to OCR.

Projectbeta

Overview

doc-router avoids paying to OCR pages that already have usable text. Most PDFs mix scanned and text pages, so it inspects a PDF page by page, decides which pages have a usable text layer and which need OCR, extracts the text pages locally in-process, sends only the rest to your OCR provider through a LiteLLM gateway, and merges both halves back into one page-ordered result. The core library never touches the network.

Jev is the page judge: given the evidence for a page, it answers whether this page needs OCR, catching cases rules miss such as a scan with a bad existing OCR layer, a page whose only text is a watermark, or a broken character map. The judge is a swappable trait, and a zero-dependency local heuristic is the default. The README reports, on 19 documents and 155 pages, 1.72x faster and 1.74x cheaper processing, with 9 pages wrongly skipped versus 28 for a rules-based judge, and the judge costing 2.5% of the OCR bill.

What the decision model decides

TypeQuestionAnswers
Yes / noDoes this page need OCR?yes · no

How it works

  1. Inspect each PDF page and gather text-layer evidence
  2. Jev (or the local heuristic) judges whether OCR is needed
  3. Extract text pages locally; send OCR pages through LiteLLM
  4. Merge results in page order

Strengths

  • Fewer billed OCR pages and faster runs as reported
  • Catches broken text layers that rules miss
  • Vendor-neutral OCR via LiteLLM
  • Local heuristic default with no network

Caveats

  • Some pages that needed OCR were still missed in testing
  • Small evaluation set

Getting started

cargo build --release (Rust 1.88+), then cargo run -q -p doc-router-cli -- classify ~/Documents/contract.pdf.

At a glance

Type
Project
Status
beta
Language
Rust
Runtime
CLI / library
Has code
yes

Use cases and integrations

How curated lists describe it

  • Rust tool that asks Jev which PDF pages actually need OCR, extracting text pages locally and sending only the rest to your OCR provider.

    MrJev/awesome-jev

Frequently asked questions

What does Jev decide?

Whether each PDF page needs OCR or already has usable text.

How much does it save?

The README reports about 1.74x lower OCR cost on its test set.

Does it require Jev?

No, a local heuristic judge is the default; Jev is a swappable option.

Related projects

  • Classifies tax PDF pages into 261 IRS forms and 7 page kinds with one Jev request per page and a confidence gate.

    ProjectproductionTypeScript
  • Docker service that classifies the Paperless-ngx inbox with Jev (or local Clef via Ollama), setting confident fields and queueing the rest.

    Projectbeta
  • Daily pipeline that reads Spain's official gazette with Jev, scoring relevance, tagging categories and picking a summary paragraph.

    AppprototypeTypeScript
  • Library, CLI and app that classify PDFs, DOCX and PPTX with Jev and split document packets at predicted boundaries.

    BenchmarkbetaPython
  • Local library that turns an image into a transparent text state (OCR, boxes, labels) so Jev can decide over screenshots.

    ProjectbetaPython
  • Windows office workbench with search, OCR and batch renaming, where Jev optionally helps pick extracted contract fields.

    ProjectbetaRust