---
title: "OCR a multipage TIFF in C#"
url: https://recursiveai.org/oneocr/cookbook/ocr-multipage-tiff/
description: "Read every frame of a multipage TIFF in C# with OneOcr, keep page indexes, and run a downloadable two-page example."
version: "1.0.0"
---

# OCR a multipage TIFF in C#

**OneOcr** is a free, open-source OCR library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneOcr) · [GitHub](https://github.com/recursive-ai-oss/oneocr-csharp) · [Docs](https://recursiveai.org/oneocr/docs/) · [Download example (.zip)](https://recursiveai.org/oneocr/cookbook/ocr-multipage-tiff/ocr-multipage-tiff.zip)

Read all frames in a TIFF. The zip includes the two-page `pages.tiff`.

```shell
dotnet add package RecursiveAI.OneOcr
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
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](https://recursiveai.org/oneocr/cookbook/ocr-multipage-tiff/ocr-multipage-tiff.zip), then `dotnet run`.

The snippet at the top prints:

```text
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.

```csharp
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());
```

```text
Page 10: FIRST PAGE
Page 11: SECOND PAGE
```

## Related recipes

- [Convert a scanned page to Markdown](https://recursiveai.org/oneocr/cookbook/convert-scanned-page-to-markdown/)
- [Extract text from an image](https://recursiveai.org/oneocr/cookbook/extract-text-from-image/)
- [Save OCR results as JSON](https://recursiveai.org/oneocr/cookbook/page-json/)

## 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](https://recursiveai.org/oneocr/docs/overview/) 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.
