-
OCR for scanned PDFs and images (new input ocr, default auto): the pages of a PDF without a usable text layer (all pages of a scan, NO_TEXT_LAYER, or of a PDF whose characters are all unreadable, GARBLED_TEXT; or the empty pages of a PDF where half or more of the pages have no text, the others keeping their text layer) and PNG, JPEG and WebP images are read by the AI model Google Gemini 2.5 Flash-Lite (google/gemini-2.5-flash-lite) through Apify's official apify/openrouter Actor, with the run's own token. always reads every PDF page by OCR; off is the 0.1 behaviour and sends nothing to any AI. DOCX files are never OCR'd. A PDF whose text only looks garbled (garbledSuspected) keeps its text as before (not charged) and its row suggests always.
-
Pages are drawn with pdf.js and @napi-rs/canvas (new dependency, 1.1.1) in a second worker thread under the same memory watchdog, about 2,000 px on the long side, with pdf.js's WebAssembly decoders for JBIG2, CCITT fax and JPEG 2000 scans (without them such scans drew as blank pages without an error). A page or image taller than 1:1.45 is cut into parts of at most 1:1.41 at the lightest band between lines; each part is one OCR page. Pages with almost no ink are not sent and not charged. Up to 4 requests at a time; results in page order, merged with the text-layer pages. Plain-text answers with fixed instructions (reading order, paragraphs, no spaces between Japanese characters, tategaki, tables as Markdown or tab-separated cells); a comment instead of the text is asked for once more and then fails the page; an answer cut by the 2,048-token limit is redone in halves (depth 2). 429 is retried 4 times, server errors twice; 401, 402, 403 and 404 stop the run.
-
Images as input from links, uploads and the key-value store (with OCR off, images in a store are skipped as before). Images over 25 MB or 60 megapixels (read from the header before decoding) and TIFF, HEIC, AVIF, GIF and BMP fail with a reason and are not charged. Link downloads now accept image types (the first bytes decide; SVG is refused).
-
New event page-ocr: one per OCR page whose OCR gave text. document-extracted now counts only the pages whose text came from the text layer. Blank pages, failed pages and pages left by a limit are free. Before a page is sent to the AI, the rest of the maximum cost per run must cover one more page-ocr for it (on top of the pages in flight); otherwise OCR stops there and the run ends PARTIAL. Both events are charged after the rows and the checkpoint; the Actor's own counts (an upper bound saved before each charge, and the count the SDK confirmed) carry over a migration or a resurrect, as in Audio & Video to Text.
-
AI spend caps (the maximum cost per run does not limit the AI bill): maxOcrPages per run, empty = 200 on a paid Apify plan and 20 on the Free plan (APIFY_USER_IS_PAYING, or unknown on Apify); every request, retries and halves included, counts towards a hard limit of twice that, written ahead to the run's store (OCR-SENT) before the request goes out. When a cap is reached, the rest of the run reads text layers only and the rows say how many pages were left and why.
-
Resume per OCR page: the pages read for the file in work are saved (OCR-000001 ...), so a moved, killed or resurrected run does not send them to the AI again; the record is removed after the file. "aborting" and the timeout keep the pages read (charged for them); "migrating" abandons the file without a row.
-
Rows: new fields textSource, ocrPages, ocrBlankPages, ocrFailedPages, ocrPagesLeft, ocrNote, ocrPrepared, chargedOcrPages; format can be png, jpeg or webp. OUTPUT: chargedOcrEvents, ocr counts, aiUsage (requests, tokens, the cost OpenRouter reported), sampleOcrPrepared, selfTest, and the OCR settings.
-
A third built-in sample: a scanned page (English and Japanese, written for this Actor, scripts/make-ocr-sample.js). The default run draws it like any scan and shows its known text as a prepared OCR result: no AI call, no charge. Input {"selfTest": true} (not in the form) sends it to the real AI and writes the character error rate to OUTPUT.selfTest (no charges of this Actor).
-
Dockerfile: optional packages are installed again (--include=optional) for the canvas binary of Alpine (musl); the build check now draws the scanned sample and three check scans (CCITT, JBIG2, JPEG 2000 in sample/check, scripts/make-scan-fixtures.py) and decodes PNG, JPEG and WebP, and fails the build if it cannot.
-
After the live check of build 0.2.1 and the review (2026-11-14, REVIEW-5):
- OCR text follows
lineJoin: the AI is asked for one line per paragraph (smart) or the page's line breaks (keep), and with smart the lines it still leaves broken inside a paragraph are joined as in the text layer (table rows, list items and headings never). The AI is also told to copy every character and punctuation mark exactly and never to change a word (live, it dropped the final period of many lines and once wrote another word). The self-test compares the row's text in the joined form (characterErrorRate; characterErrorRateNoSpaces without spaces and line breaks).
- A fixed answer format: the answer must start with the line
[[OCR]]; anything before it is dropped, an answer without it is asked for once more and then fails the page (AI_BAD_FORMAT, not charged), and [[NO_TEXT]] after it means no text (not charged). Real text that starts like a comment ("I cannot attend ...", "この画像の無断転載を禁じます。") is kept; a line such as "Here is the transcription:" is not.
- The blank check counts ink both ways around the most common brightness: dark-mode screenshots, code editors, terminals and dark slides were taken for blank. Transparent images are drawn on grey (white text on a transparent PNG was lost). Cut points use the same rule.
- Sections by height: an image is scaled down only when wider than 2,000 px, and up to 2,800 px high it is one OCR page (phone screenshots, US Legal pages: one, not two); a taller one is cut into parts of at most 2,800 px. The width is never made smaller to have fewer parts (a 800 x 75,000 image was drawn 299 px wide); past 40 parts per page or image, the rest is left (not charged) and the row says so.
- Drawing pages that turn out blank or cannot be read counts as unpaid run time inside the file, so a long PDF of slow blank pages stops at the limit instead of running until the timeout.
- A page that needs more OCR pages than
maxOcrPages has left is left alone; it no longer closes OCR for the rest of the run. The start of every page is written ahead to OCR-SENT, so a restarted run counts it against maxOcrPages.
- Smaller: with one row per page, a page that OCR could not read (or a blank one) says so in its own row; a half that fails keeps the text of the other half; sections that failed are not saved for a restart (a passing AI error is tried again); the log no longer shows the start of an answer that was not used; the memory a failed page recommends is 2 GB (scans of 600 dpi need about 585 MB more).
- After the live reboot check of build 0.2.2 (run NjX78YrLHoQGBzGVh):
maxOcrPages counts each section of a file once, by key; the keys counted for the file in work are written ahead to OCR-SENT with the count, so a page that was in flight (or read but not saved yet) when the run was moved is started again without counting a second time (5 pages counted twice and 8 of 20 pages were left). The request block written ahead is 2 instead of 8, so a restart counts at most a few unsent requests against the hard limit.
- Store title and description (
actor.json): "PDF & Image OCR to Text - Scanned PDF, Word, Japanese", with the OCR price. README: the title, sections by height, the answer format, the measured memory per scan resolution, the first OCR numbers measured on Apify, and that a cut is at the lightest band (not "never through a line").