Image & Scanned PDF OCR: Image to Text (Tesseract) avatar

Image & Scanned PDF OCR: Image to Text (Tesseract)

Pricing

$3.00 / 1,000 page read (ocr)s

Go to Apify Store
Image & Scanned PDF OCR: Image to Text (Tesseract)

Image & Scanned PDF OCR: Image to Text (Tesseract)

Image to text: reads the text in images, screenshots and scanned PDFs with Tesseract OCR, offline: no AI, no third-party API. Plain text, per-page confidence, and optional words with bounding boxes, in 27 languages. Respects robots.txt and PDF permissions. Failed files are free.

Pricing

$3.00 / 1,000 page read (ocr)s

Rating

0.0

(0)

Developer

WrenTools

WrenTools

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

17 hours ago

Last modified

Features

Limited permissions

Share

Image to text: read the text in photos, screenshots, scanned letters, receipts, forms and scanned PDFs. Give it links to image or PDF files, or send files inline as base64, and get back for each one: the text, line by line, a confidence score per page, and optionally every word with its position on the page.

Everything runs inside the Actor with Tesseract OCR and its tessdata_fast language models; for Chinese (simplified and traditional) and Japanese, tessdata_best's, which keep short lines (all Apache-2.0). Your files are not sent to any AI model or third-party API, and the result for the same file is the same every time.

If your PDFs already have a text layer (they were made by a word processor, not a scanner), the PDF to Text & Markdown Extractor reads them faster and for less. Its pagesWithoutText field tells you which pages need OCR.

One file at a time, in your browser: our Chrome extension Wren Offline OCR copies the text from a part of a web page you select, or from a picture you choose, and Offline PDF to Text & Markdown (with OCR) turns a PDF into plain text or Markdown, scanned pages included. Both read on your own computer, and nothing is uploaded. This Actor is for many files at once, or for OCR in a pipeline your code runs.

Code examples, in Python and Node, each run against this Actor before publishing: scanned PDFs and images from links, and a folder of screenshots into one searchable CSV (the files are sent inline, so they need not be online). In Python: each new scan in a folder, read every morning.

See it run: our video Automatically OCR New Scans in a Folder with Python: API Token, Fingerprints and cron runs that morning script on a made-up office's scan folder: how it tells a new scan from a copy, why the API token stays out of the script, and how to schedule it with cron. Our post on OCR of a scanned PDF at 300 dpi shows how a scanned page is read and which resolution to use, and How to make Tesseract faster: we timed the usual advice times threads, --psm, smaller pages, other models and parallel processes. We made the video; its narration is a synthetic voice.

Need the PDF itself to work with screen readers, not just its text? Our free, open-source PDF Access Fixer tags PDFs, including scans, on your own computer.

What you get

  • Text for each file, one line per printed line, with a blank line between paragraphs and blocks.
  • Confidence: meanConfidence (0-100, weighted by characters) for the file and for each page, and lowConfidencePages listing pages below 60, so you can send those for a human look.
  • Per-page results (includePages): text, confidence and the page's pixel size.
  • Words with bounding boxes (includeWords): each word's text, confidence, left, top, width and height in pixels, for parsing invoices and forms by position.
  • Reading order: columns are read one after the other, tilted scans (1 to 15 degrees) are levelled before reading, and Chinese and Japanese come out without stray spaces between characters (measured on our own test images, before and after each change).
  • 27 languages: English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Swedish, Danish, Norwegian, Finnish, Turkish, Romanian, Hungarian, Greek, Russian, Ukrainian, Vietnamese, Indonesian, Japanese, Chinese (simplified and traditional), Korean, Arabic and Hindi. Up to 3 per run.
  • Files: PNG, JPEG, TIFF (every page of a multi-page TIFF), GIF, BMP, WebP and PDF (every page rendered at pdfDpi, or lower for a page over 40 megapixels). Photos are turned upright from their EXIF orientation; transparent images are read on white.
  • pagesWithoutText lists pages where no text was found, and downscaledPages lists pages that were read smaller: pages over 40 megapixels (an image at its own size, a PDF page at pdfDpi), and pages read at a lower resolution when the run's memory holds less (see Limits).

Failed files are reported in the dataset with a reason and are not charged: fetch-failed, file-too-large, unsupported-file, unreadable-image, image-too-large, memory-too-small, unreadable-pdf, robots-disallowed, robots-disallowed-redirect (the link redirected to a URL that site's robots.txt does not allow, so it was not fetched there), password-required, extraction-not-permitted, ocr-timeout, ocr-failed, invalid-base64. A file whose whole reply takes longer than its time limit is a fetch-failed row whose message starts deadline-exceeded, and the run goes on to the next. The limit is the largest file maxFileSizeMb allows at 333 kB/s, between 60 s and 600 s (150 s at the default 50 MB). So a server that sends a file very slowly cannot hold the run.

Respectful by design

  • Only the files you name are downloaded, one request each. The site's robots.txt is read first and obeyed, and so is the robots.txt of the site any redirect leads to, before the request goes there; downloads from one site are spaced (500 ms by default). No proxy, no browser, no login.
  • PDF permissions are honoured. A PDF that needs a password is refused (the Actor takes no password), and so is a PDF whose owner has forbidden copying or extracting its text: reading its pixels back would be the same extraction.
  • Only public internet addresses are fetched: a URL or redirect into a private, loopback or link-local network is refused.

Process only documents you have the right to use.

Input

FieldTypeDefaultNotes
fileUrlsstring[]links to images or PDFs
filesBase64arraybase64 strings, or {"name": "scan.png", "data": "<base64>"}; a data: prefix is fine
languagesstring[]["eng"]1 to 3 codes, e.g. ["eng", "deu"]
pageSegmentationstringautoauto, singleColumn, singleBlock (receipts, labels), sparse (forms, photos)
includePagesbooleanfalseper-page text and confidence
includeWordsbooleanfalsewords with bounding boxes (adds pages too)
pdfDpiinteger30072 to 600; raise it for small print
maxPagesPerFileinteger100longer files are marked truncated
maxFileSizeMbinteger50larger downloads stop, uncharged
requestDelayMsinteger500pause between downloads from one site

Give fileUrls, filesBase64 or both. Results come back in input order.

Output

One dataset item per file (this is the Store example: a tilted, speckled phone scan of a notice):

{
"source": "https://example.com/scans/notice.png",
"url": "https://example.com/scans/notice.png",
"finalUrl": "https://example.com/scans/notice.png",
"fileName": "notice.png",
"status": "ok",
"error": null,
"fileType": "image",
"pageCount": 1,
"pagesProcessed": 1,
"truncated": false,
"meanConfidence": 96.4,
"pagesWithoutText": [],
"lowConfidencePages": [],
"downscaledPages": [],
"charCount": 194,
"wordCount": 31,
"text": "NOTICE OF SCHEDULED MAINTENANCE\nWater service on Alder Street will be off\n\non Tuesday 4 November from 9:00 to 13:00.\n..."
}

A failed file has "status": "error" and "error": {"code": "password-required", "message": "..."}. If a result is too large for one dataset item (over 8 MB), its text and pages are stored in the run's key-value store, and the item carries fullOutputKey and fullOutputUrl. The run's SUMMARY record counts files read and failed, and pages read.

Pricing

Pay per event, no start fee, and nothing for files that fail:

EventPricePer 1,000
page-ocr (one image, or one page of a PDF or TIFF, read)$0.003$3.00

A single image costs $0.003; a 20-page scanned PDF costs $0.06. When you set a maximum charge for a run, the Actor stops before a file it cannot pay for, and reads only the pages the remainder covers (the item is marked truncated).

Limits

  • Tesseract reads printed text well and handwriting poorly. Low-contrast photos, pages photographed at an angle and skew over 15 degrees lower the confidence, which meanConfidence shows for each page; a page below 60 is listed in lowConfidencePages, and one too faint for any text in pagesWithoutText.
  • Tables come out as text lines; their cell structure is not rebuilt. Use includeWords positions to rebuild columns.
  • A page that takes over 180 seconds is stopped and reported as ocr-timeout. Very large pages are scaled down to 40 megapixels first. A PDF page is rendered at a lower resolution than pdfDpi when that would make it larger than that, so it is never drawn larger (an A0 poster at 600 dpi would be 558 megapixels); an image is scaled down after it is opened.
  • Memory. Each page is fitted to the run's memory before it is opened or drawn, so a large page cannot end the run. At the default 2,048 MB a page is read as described above, unless it is an image too large to open in that memory (an RGB PNG or TIFF over about 350 megapixels, a transparent one over about 150) or a PDF page drawing images too large to decode in it (a grey Flate image over about 1,500 megapixels, an RGB one over about 500). With less memory, a page is read at a lower resolution when the run's memory holds less, and listed in downscaledPages: at 512 MB up to about 37 megapixels, at 256 MB about 15 (A4 at 400 dpi), at 128 MB about 5 (A4 at 225 dpi). A JPEG too large to decode whole in the run's memory is decoded at a half, a quarter or an eighth of its size. A file that does not fit at all is reported and not charged, and the run goes on to the next: image-too-large (an image, or the images a PDF page draws, too large to decode in the run's memory; the message names the memory that would fit) or memory-too-small (too little memory is left for a page of so large a file). If that happens on a later page of a PDF or TIFF, the pages before it are kept and charged, and the item is marked truncated with truncatedReason "the run's memory" and a truncatedMessage naming the page. For very large images, choose more memory (up to 4,096 MB).
  • A run stops early, before its timeout, so its results are saved: 60 s before it (a fifth of the time for a run shorter than 5 minutes) it starts no new file, and a download still running then is cut and reported as fetch-failed (deadline-exceeded), not charged. A long PDF or TIFF is stopped between pages: its item is marked truncated with truncatedReason "the run's timeout" and charged for the pages read. A page still being rendered or read 10 s before the timeout is cut (half the margin, for a run shorter than 5 minutes) and not charged: the file keeps the pages read before it, marked the same way, or, if it was the file's first page, is reported as ocr-timeout. Files not started are not in the dataset and not charged, and SUMMARY.stoppedReason says why the run stopped.