Load the bundled OCR engine once, load the image, and call ToText. The program below reads a sample invoice, a 300 DPI PNG you can download to try it.
dotnet new console -o ImageToText && cd ImageToText dotnet add package RecursiveAI.OneOcr --version 1.0.0 curl -O https://recursiveai.org/oneocr/samples/invoice.png
Put this in Program.cs and run dotnet run:
using OneImage; using OneOcr; // Load once at startup; the engine is immutable and safe to share across threads. OcrEngine engine = OcrEngine.LoadBundled(); Image image = Image.Load("invoice.png"); // PNG, JPEG, WebP, TIFF, BMP, GIF Console.WriteLine(image.ToText(engine));
Northwind Supply Ltd 14 Harbour Street BS1 4DJ Bristol United Kingdom VAT ID: GB284193752 INVOICE Bill to Blue Heron Bakery 88 Elm Road OX1 2JD Oxford United Kingdom Invoice no. INV-2041 Date 14/10/2026 Due date 13/11/2026 Order no. PO-7731 Description Qty Unit price VAT Amount Flour, 25 kg bag 4 pcs 31.50 0% 126.00 Cane sugar, 10 kg 2 pcs 18.25 0% 36.50 Baking parchment roll 6 pcs 7.40 20% 44.40 Subtotal VAT total Total £206.90 £8.88 £215.78 Payment terms: Payable within 30 days BAN: GB33 BUKB 2020 1555 5555 55 BIC: BUKBGB22 Tel. +44 117 496 0321
That is the whole page, in reading order: lines end with a newline and the cells of a table are separated by a tab. One word is wrong: the footer’s “IBAN:” came back as “BAN:”, at 97% confidence, so check values that matter. The models ship inside the NuGet package, so there is nothing else to install, no tessdata folder, and nothing is sent over the network.
Words and their bounding boxes
Ocr returns the page model instead of a string: blocks, lines and words, each with a box in pixels from the top left and a confidence:
using OneImage; using OneOcr; OcrEngine engine = OcrEngine.LoadBundled(); OcrPage page = Image.Load("invoice.png").Ocr(engine); Console.WriteLine($"{page.Width} x {page.Height} px, {page.Words.Count} words"); foreach (OcrWord word in page.Words.Take(5)) { OcrBox b = word.Box; Console.WriteLine($"{word.Text,-10} {word.Confidence:P0} " + $"({b.Left:F0}, {b.Top:F0}) to ({b.Right:F0}, {b.Bottom:F0})"); }
2481 x 3509 px, 98 words Northwind 100% (206, 205) to (457, 245) Supply 100% (485, 205) to (648, 249) Ltd 92% (673, 207) to (740, 245) 14 100% (205, 280) to (242, 308) Harbour 99% (260, 278) to (403, 309)
Confidence is the calibrated probability that the word is exactly right; Get OCR confidence scores shows how to use it. Every word, line and block also has a Source saying where it came from.
Limits
- Printed text in Latin, Greek and Cyrillic scripts. That includes the EU languages, Turkish and Vietnamese, all in one model with no language to choose. Chinese, Japanese, Korean, Arabic and Indic scripts, handwriting and text in street photos aren’t read yet.
- One page per call.
OcrandToTextthrowArgumentExceptionfor an image with several frames;OcrPagesreads every page of a multi-page TIFF. - .NET 10. The packages target
net10.0.
For scanned PDFs, see OCR a PDF; for tables, Extract a table from an image. The full walk-through is in Getting started.