Using Custom Language Files

Iron Tesseract OCR fully supports custom or downloaded languages and fonts following the Tesseract .traineddata file format standard (version 4 or above). You can find such files commonly on [Github.com]().

If you wish to train your own custom font support or language pack, we recommend reading our tutorial on creating custom tesseract language packs.

using IronOcr;
using System;

class Program
{
    static void Main()
    {
        // Create an instance of the IronTesseract class which provides OCR functionality.
        var Ocr = new IronTesseract();

        // Specify the file path to your custom trained language data file.
        Ocr.Language = OcrLanguage.FromFile("path/to/your/custom.traineddata");

        // Create an OcrInput object using the path to the image file you want to process.
        var input = new OcrInput("path/to/your/image.png");

        // Use the Read method of IronTesseract to perform OCR on the input image.
        // This method processes the image and extracts text based on the specified language file.
        var result = Ocr.Read(input);

        // Output the recognized text to the console.
        Console.WriteLine(result.Text);
    }
}
using IronOcr;
using System;

class Program
{
    static void Main()
    {
        // Create an instance of the IronTesseract class which provides OCR functionality.
        var Ocr = new IronTesseract();

        // Specify the file path to your custom trained language data file.
        Ocr.Language = OcrLanguage.FromFile("path/to/your/custom.traineddata");

        // Create an OcrInput object using the path to the image file you want to process.
        var input = new OcrInput("path/to/your/image.png");

        // Use the Read method of IronTesseract to perform OCR on the input image.
        // This method processes the image and extracts text based on the specified language file.
        var result = Ocr.Read(input);

        // Output the recognized text to the console.
        Console.WriteLine(result.Text);
    }
}
Imports IronOcr
Imports System

Friend Class Program
	Shared Sub Main()
		' Create an instance of the IronTesseract class which provides OCR functionality.
		Dim Ocr = New IronTesseract()

		' Specify the file path to your custom trained language data file.
		Ocr.Language = OcrLanguage.FromFile("path/to/your/custom.traineddata")

		' Create an OcrInput object using the path to the image file you want to process.
		Dim input = New OcrInput("path/to/your/image.png")

		' Use the Read method of IronTesseract to perform OCR on the input image.
		' This method processes the image and extracts text based on the specified language file.
		Dim result = Ocr.Read(input)

		' Output the recognized text to the console.
		Console.WriteLine(result.Text)
	End Sub
End Class
$vbLabelText   $csharpLabel

This C# code demonstrates how to use the IronTesseract library to perform OCR (Optical Character Recognition) with a custom language model. It involves setting up the language model, preparing the image input, and executing the OCR process to extract text, which is then printed to the console.