Recursive AI

OCR in C#: Text, layout, and PDFs

Run OCR in C# on .NET 10 with OneOcr. Choose plain text, word boxes, structured page data, or a separate PDF package for scanned documents.

OneOcr is a free, open-source C# OCR library from Recursive AI, licensed under MIT or Apache-2.0. NuGet · GitHub

Install · .NET 10
dotnet new console
dotnet add package RecursiveAI.OneOcr --version 1.1.0

Save notice.png beside Program.cs. The OneOcr package installs OneImage as a dependency.

Program.cs · .NET 10
using OneImage;
using OneOcr;
 
var engine = OcrEngine.LoadBundled();
var page = Image.Load("notice.png").Ocr(engine);
Console.WriteLine(page.Text);
Console.WriteLine($"Words with positions: {page.Words.Count}");
Output from dotnet run
North entrance
Words with positions: 2

Choose what to keep from the page

KeepHow
Plain textToText returns a string in reading order for search or indexing, without word positions.
Page layoutOcr returns an OcrPage with word boxes, confidence, and table structure. Save as oneocr.page JSON to pass those details on.
MarkdownConvert the page you already read to keep inferred headings, lists, and tables without running OCR again.

Keep the page result if someone needs to check a misread part number against the scan: the word box tells you where to look. If nobody needs that link back to the image, a plain string is usually enough.

What ships with local OCR

The base NuGet package brings in RecursiveAI.OneOcr.Models. Its embedded weights provide the recognizer, page detector, and word models. OcrEngine.LoadBundled() loads them locally; it doesn’t fetch a model or call an OCR service. The engine runs on the CPU and can be shared across calls.

The bundled recognizer covers printed Latin (including Turkish and Vietnamese), Greek, and Cyrillic. It isn’t a handwriting recognizer. Test on scans like the ones your app will receive before treating OCR text as exact. See the model coverage and package list for this release.

When a PDF needs OCR

Start with text extraction if the PDF already has a usable text layer. Use RecursiveAI.OneOcr.Pdf if your input is a scan or a mix of selectable text and scanned regions. The PDF bridge reads existing text and recognizes image regions. You don’t need the PDF package for a PNG or JPEG.

Choose OCR a PDF when your app needs the recognized text or page results. Choose make a scanned PDF searchable when the deliverable is a PDF that still looks like the scan but lets the reader select or search the words.