# Prerequisites

**Optical Character Recognition** (also known as OCR) is the electronic or mechanical conversion of images of typed, handwritten, or printed text into machine-encoded text from a scanned document.

This topic describes the requirements for the [PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/overview) library to use `OcrFormatProvider`.

> important The default Tesseract implementation is at this point **Windows** and **Linux-only**. You can still use the OCR feature with a [custom implementation](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/custom-ocr-provider).

> note Used images must be **300 DPI** for best results.

## Required Packages

To use `OcrFormatProvider`, add the following packages:

<table>
<thead>
	<tr>
		<th>.NET Framework </th>
		<th>.NET Standard-compatible</th>
	</tr>
</thead>
<tbody>
	<tr>
		<td><b>Telerik.Windows.Documents.Core</b></td>
		<td><b>Telerik.Documents.Core</b></td>
	</tr>
	<tr>
	    <td><b>Telerik.Windows.Documents.Fixed</b></td>
		<td><b>Telerik.Documents.Fixed</b></td>
	</tr>
    <tr>
	    <td><b>Telerik.Windows.Documents.Fixed.FormatProviders.Ocr</b></td>
		<td><b>Telerik.Documents.Fixed.FormatProviders.Ocr</b></td>
	</tr>
     </tr>
		<tr>
	    <td colspan="2">&nbsp;</td>
	</tr>
    <tr>
    <td colspan="2">
        Always add this reference as a NuGet package. It adds the required Tesseract references and files automatically. Otherwise, a 
        <a href="#manually-set-up-the-tesseract-native-assemblies">manual setup</a> might be required.
    </td>
</tr>
        <tr>
	    <td><b>Telerik.Windows.Documents.TesseractOcr</b></td>
		<td><b>Telerik.Documents.TesseractOcr</b></td>
	</tr>
    </tr>
		<tr>
	    <td colspan="2">&nbsp;</td>
	</tr>
	<tr>
        <td colspan="2">To export images different than <b>Jpeg</b> and <b>Jpeg2000</b> or ImageQuality different than High, add a reference to the following assembly:</td> 
    </tr>
	<tr>
	    <td><b>-</b></td>
		<td><b>Telerik.Documents.ImageUtils</b>
	</tr>
    <tr>
	    <td><b>-</b></td>
		<td>
        <b><a href="https://www.nuget.org/packages/SkiaSharp/">SkiaSharp</a></b>
        <br>
        <sub><i>Telerik.Documents.ImageUtils depends on SkiaSharp.</i></sub>
    </td>
	</tr>
	<tr>
        <td><b>-</b></td>
		<td>
        <b>SkiaSharp.NativeAssets.*</b> (version 3.119.1)
        <br>
        <sub><i>May differ according to the used platform. For <b>Linux</b> (starting with <b>Q2 2025</b>) use <b>SkiaSharp.NativeAssets.Linux.NoDependencies</b> and execute the <a href="#linux-specific-steps">required commands.</a></i></sub>
	</tr>
	<tr>
        <td><b>-</b></td>
		<td>
        <b>SkiaSharp.Views.Blazor</b> and <b>wasm-tools</b>
        <br>
        <sub><i>For Blazor Web Assembly.</i></sub>
	</tr>
</tbody>
</table>

> important Verify that all [Tesseract dependencies are properly set up](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/prerequisites#manually-set-up-the-tesseract-native-assemblies).

## Language Data Setup

Create a "**tessdata**" folder and populate it with the desired languages. The languages are in the form of *.traineddata* files and are crucial for Tesseract OCR because they contain the machine learning models that Tesseract uses to recognize text. English (eng.traineddata) is always required by default. You can download the language data files from the official [Tesseract GitHub repository](https://github.com/tesseract-ocr/tessdata/tree/3.04.00). Results may vary depending on the language version:

![Tesseract Languages Version](https://www.telerik.com/document-processing-libraries/documentation/assets/d27c1d0c68792aa820b867c658ef6a7b/tesseract-languages-version.png)

The "**tessdata**" folder placement is determined by the user. The `DataPath` property of the [TesseractOcrProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/ocrformatprovider#tesseractocrprovider-public-api) points to the parent folder that contains "**tessdata**", which allows the provider to locate and use it.

### "tessdata" Structure:

```plaintext
tessdata
├── due.traineddata
├── eng.traineddata     
└── spa.traineddata
```

## Manually Set Up the Tesseract Native Assemblies

Verify that the following files exist in the root directory of your project:

* The `Tesseract.dll` assembly.
* The Tesseract native assemblies (x86, x64):

  ![Tesseract Native Assemblies Structure](https://www.telerik.com/document-processing-libraries/documentation/assets/d919a0de043f7662911ecf33f4ea6fbd/tesseract-native-assemblies-structure.png)

If these requirements are not met, go through the following steps:

1. Download the `tesseract50.dll` and `leptonica-1.82.0.dll` native assemblies from the listed links:
   * <https://github.com/charlesw/tesseract/tree/master/src/Tesseract/x64>.
   * <https://github.com/charlesw/tesseract/tree/master/src/Tesseract/x86>.
2. Create the following structure and add the two folders to the root of the application.
   * Folder Structure:
   ```plaintext
   RootFolder
   ├── x64
   │   ├── tesseract50.dll
   │   └── leptonica-1.82.0.dll
   └── x86
       ├── tesseract50.dll
       └── leptonica-1.82.0.dll
   ```

### Linux-Specific Steps

Execute the following commands in the environment:

| Ubuntu                              | Alpine                       | Fedora                       |
| ----------------------------------- | ---------------------------- | ---------------------------- |
| `sudo apt update`                   | `sudo apk update`            | `sudo dnf install tesseract` |
| `sudo apt install tesseract-ocr`    | `sudo apk add tesseract-ocr` | `sudo dnf install leptonica` |
| `sudo apt install libleptonica-dev` | `sudo apk add leptonica`     |                              |

> caution If the generated **tesseract/leptonica** .so files cannot be found, they were likely installed with different names than expected. Copy their names and location, and set them to the corresponding properties:
>
> * `TesseractEnvironment.TesseractUnixLibName`
> * `TesseractEnvironment.LeptonicaUnixLibName`
> * `TesseractEnvironment.CustomSearchPath`

## See Also

* [Using OcrFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/ocrformatprovider)
* [Implementing a Custom OCR Provider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/custom-ocr-provider)
* [Cross-Platform Images](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/cross-platform/images)
