Tools,

Self-hosted OCR: 4 servers tested

139 MiB

peak RAM: our Tesseract API, a page a request

Get the 4 commands

All 4 found 94% to 96% of words

10 scanned book pages, 1,955 true words, 2 CPUs each
Server Words found Seconds
Apache Tika 1,881 9.2
Tesseract API 1,877 10.3
Stirling-PDF 1,853 12.1
docling-serve 1,844 34.1

Seconds are for all 10 pages, on the second run. The first docling-serve run took 42.2.

Peak RAM: 139 MiB to 3.0 GiB

What each server takes on your box
Server Image Peak RAM
Tesseract API 0.34 GB 139 MiB
Apache Tika 2.01 GB 997 MiB
Stirling-PDF 3.35 GB 1.5 GiB
docling-serve 7.20 GB 3.0 GiB

The Tesseract API got one page image a request. The other 3 got the whole PDF. Image is the arm64 size from docker image inspect (1 GB = 10^9 bytes).

Start a server, send the scan

Each block starts a server. When it is up, the last line sends the scan (Tesseract API: page 1).

# Tesseract API: Dockerfile and server.py from /tesseract-ocr-api/
docker build -t tesseract-api .
docker run -d -p 127.0.0.1:8884:8884 -e OCR_TOKEN=pick-one tesseract-api
curl -H "Authorization: Bearer pick-one" --data-binary @page.jpg "localhost:8884/?lang=eng"

# Apache Tika
docker run -d -p 127.0.0.1:9998:9998 apache/tika:latest-full
curl -T scan.pdf localhost:9998/tika/text > scan.txt

# Stirling-PDF
docker run -d -p 127.0.0.1:8080:8080 -e SECURITY_ENABLELOGIN=false stirlingtools/stirling-pdf:latest
curl -F fileInput=@scan.pdf -F languages=eng localhost:8080/api/v1/misc/ocr-pdf -o scan-ocr.pdf

# docling-serve
docker run -d -p 127.0.0.1:5001:5001 -e DOCLING_SERVE_MAX_SYNC_WAIT=600 quay.io/docling-project/docling-serve-cpu
curl -F files=@scan.pdf -F to_formats=md localhost:5001/v1/convert/file | jq -r .document.md_content > scan.md

SECURITY_ENABLELOGIN=false turns off the Stirling-PDF login. Keep the port on 127.0.0.1.

Pick by what you need back

No server: our Actor

Our Apify Actor turns scanned PDFs into text or Markdown. Its code at build 0.1.97 found 1,879 of the 1,955 words on the same 10 page images.

A scanned page costs $0.006, and pages with a text layer are free.

Try the Actor

How I tested it
  • The scan: 10 proofread pages from 2 books on Wikisource, as 1920 px JPEGs in one PDF. The same 10 pages, byte for byte, as our 28-engine test.
  • Each server in a fresh container with --cpus 2, one at a time, in Docker Desktop on an arm64 Mac.
  • Words found counts the true words in the right order. Extra words do not lower it.
  • Each server read the scan twice, with the same words both times.
  • Peak RAM comes from docker stats, one call after another, so a short spike can slip by.
  • Other work ran on the Mac: 210% to 532% at each start. The seconds are a guide, not a speed ranking.
  • The 4 blocks above ran as printed, with --cpus 2 added, and found the same word counts. For docker build, our Nov 4 build of the same Dockerfile stood in. The Tesseract API block reads page 1 only: 196 of its 202 words.
  • The Actor's code ran on our Mac, not on Apify.
  • Not tested: PaddleOCR (its API crashed on arm64 in our Docker test), GPUs, other languages, many requests at once, x86 servers.
Version, and seconds to start (image already on disk)
Server Version Start
Tesseract API Tesseract 5.5.0 0.9
Apache Tika 4.2.0 2.3
Stirling-PDF 3.4.0 10.8
docling-serve 1.38.2 7.8

Questions people ask

What is the best self-hosted OCR?

On our 10-page scan, Apache Tika found the most words (1,881 of 1,955), 4 more than our Tesseract API. The Tesseract API used the least RAM (139 MiB).

How much RAM does a self-hosted OCR server need?

On 10 pages, peak RAM went from 139 MiB (Tesseract API) to 3.0 GiB (docling-serve). Apache Tika used 997 MiB and Stirling-PDF 1.5 GiB.

Can I put a self-hosted OCR server online?

Not as shown here. Of these commands, only the Tesseract API asks for a token. Keep the port on 127.0.0.1, or put a login in front of it.