---
title: "OCR Arabic text in C#"
url: https://recursiveai.org/oneocr/cookbook/ocr-arabic-text-csharp/
description: "Extract printed Arabic text from a PNG in C# using OneOcr and its Arabic model. Compare the source with the exact Unicode output."
version: "1.2.1"
---

# OCR Arabic text 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.Models.Arabic) · [GitHub](https://github.com/recursive-ai-oss/oneocr-csharp) · [Docs](https://recursiveai.org/oneocr/docs/) · [Download example (.zip)](https://recursiveai.org/oneocr/cookbook/ocr-arabic-text-csharp/ocr-arabic-text-csharp.zip)

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

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

```csharp
// RecursiveAI.OneOcr brings in OneImage.
using OneImage;
using OneOcr;

var engine = OcrEngine.LoadBundled()
    .WithoutDetector();
var image = Image.Load("notice.png");
Console.WriteLine(image.ToText(engine));
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/oneocr/cookbook/ocr-arabic-text-csharp/ocr-arabic-text-csharp.zip) and `dotnet run`.

The printed text in `notice.png` (included in the zip):

```text
المكتبة مفتوحة اليوم
يرجى إغلاق الباب
```

What the example prints:

```text
المكتبة مفتوحة اليوم
يرجى إغلاق الباب
```

The example uses OneOcr’s built-in line finder via `WithoutDetector()`. On this two-line notice, the default page detector split the text and returned fragments; the built-in finder read both lines.
Try `WithoutDetector()` for a single block of text, such as a sign or notice;
keep the default detector for pages with columns or photos.
If an Arabic line is left unread, check that the Arabic model is installed in the app that runs the OCR, not just in a different project in the solution.

## Variations

**Use an Arabic language hint.** Replace the last line when you know the page is Arabic:

```csharp
var options = new OcrOptions { Languages = ["ar"] };
Console.WriteLine(image.ToText(engine, options));
```

## Related recipes

- [Extract text from an image](https://recursiveai.org/oneocr/cookbook/extract-text-from-image/)
- [OCR a PDF in C#](https://recursiveai.org/oneocr/cookbook/ocr-pdf/)

---

## The short answer

Install `RecursiveAI.OneOcr` and `RecursiveAI.OneOcr.Models.Arabic`, then call `image.ToText(engine)` on a PNG loaded with `Image.Load`. The Arabic package adds the recognizer for Arabic, Persian and Urdu. The example reads printed text and returns a C# string, not a translation.

## How do you convert an Arabic image to text without uploading it?

The NuGet package places the Arabic model in `oneocr-models/` beside the application. `OcrEngine.LoadBundled()` picks it up there, checks the model and makes it available to the local OCR engine. There’s no separate model download at runtime. If you’re moving the app to another machine, deploy the model directory with the rest of the application output.

There are two distinct steps: finding the rows of text in the image, and recognizing the characters in those rows. Switching to `WithoutDetector()` changes the first step, not the Arabic model. It helped on the plain notice above. For a scan with columns or photos, try the default detector first and compare the reading order and line breaks against the original. A language hint narrows the set of recognizers; it doesn’t tell the engine where the lines are. Leave it off if you want the engine to pick among the installed scripts.

Arabic text comes back in logical Unicode order: the order you would type it. Display it in a right-to-left-aware editor or UI; don’t reverse the string. The [script documentation](https://recursiveai.org/oneocr/docs/overview/#other-scripts-chinese-japanese-korean-arabic-hebrew-and-indic) also describes how OneOcr handles left-to-right runs such as digits inside right-to-left lines. If a label contains an important number or a word distinguished by a dot, compare that field against the pixels before using the result.
