New to Telerik Document ProcessingStart a free 30-day trial

Using OcrFormatProvider

Updated on Feb 19, 2026
Minimum VersionQ1 2025

RadPdfProcessing supports Optical Character Recognition (OCR). OCR is the electronic or mechanical conversion of images of typed, handwritten, or printed text into machine-encoded text from a scanned document. The library uses the OcrFormatProvider class that allows you to import an image which is returned as a RadFixedPage. By default, the OcrFormatProvider takes as a parameter a TesseractOcrProvider implementation which is achieved by using the third-party library Tesseract, however you can provide any custom implementation instead.

PdfProcessing Optical Character Recognition (OCR) Demo

You can find all the dependencies and required steps for the implementation in the Prerequisites article.

TesseractOcrProvider Public API

Method/PropertyDescription
TesseractOcrProvider(string dataPath)Constructor that takes as a parameter the path to the parent directory that contains the "tessdata" folder.
LanguageCodesThe language codes to use for the Tesseract OCR engine. You can find the corresponding trained data for each language and their codes here. The value is "eng" by default.
CorrectVerticalPositionIndicates whether the OCR processor will try to correct the vertical position of the text. (Not available in .NET Framework)
DataPathThe path to the parent directory that contains the "tessdata" folder.
ParseLevelIndicates the level of parsing that the OCR processor will perform - OcrParseLevel.Line or OcrParseLevel.Word.
GetAllTextFromImageExtracts all text from an image and returns it as a single string.
GetTextFromImageExtracts the text from an image and returns the words and their bounding rectangles.
c#
// Requirement for Images in .NET Standard - https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform/images
//FixedExtensibilityManager.ImagePropertiesResolver = new ImagePropertiesResolver();

TesseractOcrProvider tesseractOcrProvider = new TesseractOcrProvider(".");
tesseractOcrProvider.LanguageCodes = new List<string>() { "eng" };
//tesseractOcrProvider.CorrectVerticalPosition = false; // Available in .NET Standard
tesseractOcrProvider.DataPath = @"..\..\..\";
tesseractOcrProvider.ParseLevel = OcrParseLevel.Line;

string imagePath = @"..\..\..\images\image.png";

string imageText = tesseractOcrProvider.GetAllTextFromImage(File.ReadAllBytes(imagePath));
Dictionary<Rectangle, string> imageTextAndTextDimentions = tesseractOcrProvider.GetTextFromImage(File.ReadAllBytes(imagePath));

OcrFormatProvider OcrProvider = new OcrFormatProvider(tesseractOcrProvider);

RadFixedDocument document = new RadFixedDocument();

RadFixedPage page = new RadFixedPage();
page = OcrProvider.Import(new FileStream(imagePath, FileMode.Open), null);
document.Pages.Add(page);

string outputPath = "output.pdf";
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
using (Stream output = File.OpenWrite(outputPath))
{
    pdfFormatProvider.Export(document, output, TimeSpan.FromSeconds(10));
}

You can find a complete example of implementing an OcrFormatProvider in our SDK repository.

See Also