Read all frames in a TIFF. The zip includes the two-page pages.tiff.
dotnet add package RecursiveAI.OneOcrRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneOcr; var engine = OcrEngine.LoadBundled(); var pages = engine.OcrPages("pages.tiff"); foreach (var page in pages) Console.WriteLine($"Page {page.Index}: " + page.Text.Trim());
The sample TIFF contains “FIRST PAGE” on its first frame and “SECOND PAGE” on its second. The program prints both, with zero-based page indexes.
An input over the pixel or page limits throws OcrLimitException.
Unzip the example, then dotnet run.
The snippet at the top prints:
Page 0: FIRST PAGE Page 1: SECOND PAGE
Variations
Read TIFF bytes, for example after receiving an upload, and start the page indexes at 10.
using OneOcr; var engine = OcrEngine.LoadBundled(); byte[] bytes = File.ReadAllBytes("pages.tiff"); var pages = engine.OcrPages(bytes, new OcrOptions { PageIndex = 10 }); foreach (var page in pages) Console.WriteLine($"Page {page.Index}: " + page.Text.Trim());
Page 10: FIRST PAGE Page 11: SECOND PAGE
Related recipes
The short answer
Use engine.OcrPages("pages.tiff") to recognize every frame of a multipage TIFF in C#. It returns an ordered collection of OcrPage objects, not just the first image. Read page.Text for each page and keep page.Index alongside it. The example deliberately uses different words on the two frames so you can see that both were read.
Recognition runs locally. Create the engine once and reuse it when processing more files.
How do I OCR a multipage TIFF in C#?
Pass the file path to OcrPages, as in the complete example above. The README’s multipage-file documentation also supports a stream, byte array or loaded Image. Path, stream and byte inputs let the library apply pixel and frame limits before decoding the pixels. Use one of those overloads when the TIFF comes from an upload rather than from a trusted local source.
The returned indexes are consecutive. They start at zero unless you set OcrOptions.PageIndex; the variation starts at 10 to show how to fit one TIFF into a larger document. Keep the original filename too if you combine results from several files. An index is a position within your chosen sequence, not a persistent identifier for the document.
Do not substitute Image.Load(...).Ocr(engine) for this loop. Ocr(Image) throws ArgumentException for a loaded image containing multiple frames; use OcrPages instead. That exception is intentional: a successful response containing only the first page would make missing pages hard to notice. Catching that exception and continuing would still discard your document; change the call instead.
Use page.Text when you only need transcription. Keep each OcrPage when you also need word boxes, tables, confidence or diagnostics. Joining all the text into one string discards the explicit page boundary, so decide how to represent it before exporting. For example, an indexing application can store one record per page with the filename and index as separate fields.
Frame count counts against OcrLimits.MaxPagesPerCall. A large TIFF can therefore fail even when each individual frame is small. A pixel-limit or frame-limit failure is OcrLimitException; bytes that cannot be decoded as the claimed image format surface as OcrFormatException. Don’t interpret either exception as an empty recognized page.
Resolution is another reason to prefer the path overload. The library reads a TIFF’s declared XResolution into the page’s UnitsPerInch. If you load the Image yourself, it estimates resolution from text size and records a diagnostic instead; supply OcrOptions.Dpi when you know the actual resolution. Review important values against the scan.