Code Examples

International Language Example

Install-Package IronOcr.Languages.ChineseSimplified
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Chinese Simplified
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    // Add an image to be processed
    input.AddImage("img/chinese.gif");

    // Optional: Enhance the input by deskewing or denoising the image
    // input.Deskew();
    // input.DeNoise();

    // Process the image and retrieve the result
    var result = ocr.Read(input);

    // Store the recognized text in a string
    string testResult = result.Text;

    // Save the recognized text to a file since the console might not display Unicode characters properly
    result.SaveAsTextFile("chinese.txt");
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Chinese Simplified
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    // Add an image to be processed
    input.AddImage("img/chinese.gif");

    // Optional: Enhance the input by deskewing or denoising the image
    // input.Deskew();
    // input.DeNoise();

    // Process the image and retrieve the result
    var result = ocr.Read(input);

    // Store the recognized text in a string
    string testResult = result.Text;

    // Save the recognized text to a file since the console might not display Unicode characters properly
    result.SaveAsTextFile("chinese.txt");
}
Imports IronOcr



Private ocr = New IronTesseract()

' Set the OCR to use Chinese Simplified

ocr.Language = OcrLanguage.ChineseSimplified



Using input = New OcrInput()

	' Add an image to be processed

	input.AddImage("img/chinese.gif")



	' Optional: Enhance the input by deskewing or denoising the image

	' input.Deskew();

	' input.DeNoise();



	' Process the image and retrieve the result

	Dim result = ocr.Read(input)



	' Store the recognized text in a string

	Dim testResult As String = result.Text



	' Save the recognized text to a file since the console might not display Unicode characters properly

	result.SaveAsTextFile("chinese.txt")

End Using
$vbLabelText   $csharpLabel

Vertically Written Language Example

Dictionaries tuned for vertically written languages. Use 'Vertical' Variant of Korean and Japanese OcrLanguage.

using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Japanese Vertical language
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Japanese Vertical language
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr



Private ocr = New IronTesseract()

' Set the OCR to use Japanese Vertical language

ocr.Language = OcrLanguage.JapaneseVertical



Using input = New OcrInput("images\image.png")

	' Process the image and get the OCR result

	Dim result = ocr.Read(input)

	' Output the recognized text to the console

	Console.WriteLine(result.Text)

End Using
$vbLabelText   $csharpLabel

Custom Language Example

For using any Tesseract .traineddata language file you have downloaded or trained yourself.

using IronOcr;

var ocr = new IronTesseract();

// Use a custom Tesseract language file
ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();

// Use a custom Tesseract language file
ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr



Private ocr = New IronTesseract()



' Use a custom Tesseract language file

ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata")



Using input = New OcrInput("images\image.png")

	' Process the image and get the OCR result

	Dim result = ocr.Read(input)

	' Output the recognized text to the console

	Console.WriteLine(result.Text)

End Using
$vbLabelText   $csharpLabel

Multiple Language Example

More than one language at a time.

Install-Package IronOcr.Languages.Arabic
using IronOcr;

var ocr = new IronTesseract();

// Set the primary language to English
ocr.Language = OcrLanguage.English;
// Add Arabic as a secondary language
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    // Process the PDF and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();

// Set the primary language to English
ocr.Language = OcrLanguage.English;
// Add Arabic as a secondary language
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    // Process the PDF and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr



Private ocr = New IronTesseract()



' Set the primary language to English

ocr.Language = OcrLanguage.English

' Add Arabic as a secondary language

ocr.AddSecondaryLanguage(OcrLanguage.Arabic)

' Add any number of languages



Using input = New OcrInput("images\multi-lang.pdf")

	' Process the PDF and get the OCR result

	Dim result = ocr.Read(input)

	' Output the recognized text to the console

	Console.WriteLine(result.Text)

End Using
$vbLabelText   $csharpLabel

Faster Language Example

Dictionaries tuned for speed. Use the 'Fast' variant of any OcrLanguage.

using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the fast variant of English
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the fast variant of English
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr



Private ocr = New IronTesseract()

' Set the OCR to use the fast variant of English

ocr.Language = OcrLanguage.EnglishFast



Using input = New OcrInput("images\image.png")

	' Process the image and get the OCR result

	Dim result = ocr.Read(input)

	' Output the recognized text to the console

	Console.WriteLine(result.Text)

End Using
$vbLabelText   $csharpLabel

Higher Accuracy Detail Language Example

Dictionaries tuned for accuracy, but much slower results. Use the 'Best' variant of any OcrLanguage.

Install-Package IronOcr.Languages.French
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the best variant of French
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the best variant of French
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr



Private ocr = New IronTesseract()

' Set the OCR to use the best variant of French

ocr.Language = OcrLanguage.FrenchBest



Using input = New OcrInput("images\image.png")

	' Process the image and get the OCR result

	Dim result = ocr.Read(input)

	' Output the recognized text to the console

	Console.WriteLine(result.Text)

End Using
$vbLabelText   $csharpLabel

How To Install OCR Language Packs

Additional OCR Language packs are available for download below. Either

  • Install the NuGet package. Search NuGet for IronOcr Languages.
  • Or download the "ocrdata" file and add it to your .NET project in any folder you like. Set CopyToOutputDirectory = CopyIfNewer

Download OCR Language Packs

Help

If the language you are looking to read is not available in the list above, please get in touch with us. Many other languages are available on request.

Priority on production resources is given to IronOCR licensees, so please also consider licensing IronOCR for access to your desired language pack.