How to use OCR Language Packs in IronOCR

In this tutorial, you’ll learn how to extract text from multilingual PDF documents using IronOCR in C#. The video walks through setting up IronOCR and installing additional language packs—specifically English and Japanese. You'll see how to configure the OCR engine to support multiple languages and apply it to a sample PDF that includes both English and Japanese text. The tutorial demonstrates how to initialize the OCR engine, define the input file, and extract text using the Read method. The extracted content is then saved to a .txt file, with error handling in place for failed operations. This is a great example of how IronOCR supports global document processing by recognizing multiple languages in a single scan. Whether you're processing multilingual forms, international documents, or PDFs from global sources, this guide shows how easy it is to get accurate, language-aware OCR results in C#.

using IronOcr;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        // Initialize the OCR Engine with specific language packs (English and Japanese)
        var ocr = new IronTesseract();
        ocr.Language = OcrLanguage.English | OcrLanguage.Japanese;

        // Define the path to the PDF file to be processed
        var inputPath = @"path/to/your/sample.pdf";

        try
        {
            using (var input = new OcrInput(inputPath))
            {
                // Extract text from the PDF
                var result = ocr.Read(input);

                // Define output path for extracted text
                var outputPath = @"path/to/output.txt";

                // Save the extracted text to a .txt file
                File.WriteAllText(outputPath, result.Text);

                Console.WriteLine("Text extraction was successful. Check the output file for results.");
            }
        }
        catch (Exception e)
        {
            // Handle any exceptions that occur during processing
            Console.WriteLine("An error occurred: " + e.Message);
        }
    }
}
using IronOcr;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        // Initialize the OCR Engine with specific language packs (English and Japanese)
        var ocr = new IronTesseract();
        ocr.Language = OcrLanguage.English | OcrLanguage.Japanese;

        // Define the path to the PDF file to be processed
        var inputPath = @"path/to/your/sample.pdf";

        try
        {
            using (var input = new OcrInput(inputPath))
            {
                // Extract text from the PDF
                var result = ocr.Read(input);

                // Define output path for extracted text
                var outputPath = @"path/to/output.txt";

                // Save the extracted text to a .txt file
                File.WriteAllText(outputPath, result.Text);

                Console.WriteLine("Text extraction was successful. Check the output file for results.");
            }
        }
        catch (Exception e)
        {
            // Handle any exceptions that occur during processing
            Console.WriteLine("An error occurred: " + e.Message);
        }
    }
}
Imports IronOcr
Imports System
Imports System.IO

Friend Class Program
	Shared Sub Main()
		' Initialize the OCR Engine with specific language packs (English and Japanese)
		Dim ocr = New IronTesseract()
		ocr.Language = OcrLanguage.English Or OcrLanguage.Japanese

		' Define the path to the PDF file to be processed
		Dim inputPath = "path/to/your/sample.pdf"

		Try
			Using input = New OcrInput(inputPath)
				' Extract text from the PDF
				Dim result = ocr.Read(input)

				' Define output path for extracted text
				Dim outputPath = "path/to/output.txt"

				' Save the extracted text to a .txt file
				File.WriteAllText(outputPath, result.Text)

				Console.WriteLine("Text extraction was successful. Check the output file for results.")
			End Using
		Catch e As Exception
			' Handle any exceptions that occur during processing
			Console.WriteLine("An error occurred: " & e.Message)
		End Try
	End Sub
End Class
$vbLabelText   $csharpLabel

Further Reading: Additional OCR Language Packs

Kannaopat Udonpant
Software Engineer
Before becoming a Software Engineer, Kannapat completed a Environmental Resources PhD from Hokkaido University in Japan. While pursuing his degree, Kannapat also became a member of the Vehicle Robotics Laboratory, which is part of the Department of Bioproduction Engineering. In 2022, he leveraged his C# skills to join Iron Software's engineering team, where he focuses on IronPDF. Kannapat values his job because he learns directly from the developer who writes most of the code used in IronPDF. In addition to peer learning, Kannapat enjoys the social aspect of working at Iron Software. When he's not writing code or documentation, Kannapat can usually be found gaming on his PS5 or rewatching The Last of Us.
< PREVIOUS
Why IronOCR is better than the Tesseract 4 Nuget Package
NEXT >
How to use Multiple Languages with Tesseract