OCR (image or scanned PDF to text)
ai_ocrExtract text from images and scanned PDFs offline in English or Arabic, returning page text and mean word confidence without uploading files.
Instructions
Read the text in an image (PNG, JPEG, WebP, TIFF incl. multi-page, GIF, AVIF) or a scanned PDF with Tesseract (tesseract.js), fully offline: the English and Arabic models ship with the server and nothing is downloaded or uploaded. Languages: "eng", "ara" or "eng+ara" (default). PDF pages are rendered at 200 dpi by default. Returns the text per page and the mean word confidence (0-100); give "output" to also write a .txt file. Limits: up to 200 pages per call, roughly 1-5 s per page; printed text works well, handwriting and very small or skewed text poorly. For PDFs that already have a text layer, pdf_to_text is faster and exact. Give "file" as a local path or base64.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dpi | No | Render resolution for PDF pages. Default 200. | |
| psm | No | Page layout: "auto" (default), "block" (one uniform block), "line", "word", or "sparse" (scattered text). | auto |
| file | Yes | The image or PDF: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| pages | No | PDF pages / TIFF frames, e.g. "1-3, 5" (default all). | |
| output | No | Also write the text to this .txt file (or folder ending in "/"). | |
| perPage | No | Also return the text of each page separately in "pages". Default false (the joined "text" has page separators). | |
| maxChars | No | Cut the inline text after this many characters (the file is never cut). | |
| languages | No | Languages to read. Default "eng+ara". | eng+ara |