Cómo usar múltiples idiomas con Tesseract

How to use Multiple Languages with Tesseract

This article was translated from English: Does it need improvement?
Translated
View the article in English

In the realm of Optical Character Recognition (OCR) technology, IronOCR is a well-regarded tool known for its ability to extract text from various languages and scripts. We use the Tesseract Engine to provide a reliable and easy-to-use OCR tool.

In this article, we'll explore how IronOCR effectively handles text in multiple languages, thanks to Tesseract. Whether you're an experienced developer looking for a reliable multilingual OCR solution or simply curious about how it all works, this article will help you understand IronOCR and its Tesseract engine, shedding light on the capabilities of this invaluable tool.

Quickstart: Using IronOCR to Recognize Text in Multiple Languages

In just one line of code, you can configure IronOCR with a primary language and add secondary languages to extract text from documents or images in multiple languages. This setup enables developers to get up and running with multilingual OCR fast and without hassle.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. Copy and run this code snippet.

    string text = new IronTesseract { Language = OcrLanguage.Spanish }.AddSecondaryLanguage(OcrLanguage.French).Read("doc_or_image_path").Text;
  3. Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer


Read Multi-Language PDF Example

IronOcr provides about 125 language packs; however, only English is installed by default. The rest can be downloaded from NuGet. You can have a look at all the available language packs here..

In the following example, I will show you the code for using multiple languages in IronOcr to extract text from a PDF file.

:path=/static-assets/ocr/content-code-examples/how-to/ocr-multiple-languages-pdf-input.cs
using IronOcr;
using System;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Set secondary language to Russian
ocrTesseract.AddSecondaryLanguage(OcrLanguage.Russian);

// Add PDF
using var pdfInput = new OcrPdfInput(@"example.pdf");
// Perform OCR
OcrResult result = ocrTesseract.Read(pdfInput);

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

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Set secondary language to Russian
ocrTesseract.AddSecondaryLanguage(OcrLanguage.Russian)

' Add PDF
Dim pdfInput = New OcrPdfInput("example.pdf")
' Perform OCR
Dim result As OcrResult = ocrTesseract.Read(pdfInput)

' Output extracted text to console
Console.WriteLine(result.Text)
$vbLabelText   $csharpLabel

You can add any number of secondary languages using the AddSecondaryLanguage method. However, please note that this addition may affect speed and performance. The priority of the language depends on the order in which it is added, with the first added having higher priority.

Read Multi-Language Image Example

The primary language is set to English by default. To change the primary language, set the Language property to the desired language. Afterward, you can also add secondary languages.

// Example code for reading multi-language image with IronOCR
using IronOcr;

// Initialize IronTesseract OCR engine
var Ocr = new IronTesseract();

:path=/static-assets/ocr/content-code-examples/how-to/ocr-multiple-languages-image-input.cs
// Example code for reading multi-language image with IronOCR
using IronOcr;

// Initialize IronTesseract OCR engine
var Ocr = new IronTesseract();

using IronOcr;
using System;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Set primary language to Hindi
ocrTesseract.Language = OcrLanguage.Russian;
ocrTesseract.AddSecondaryLanguage(OcrLanguage.Japanese);

// Add image
using var imageInput = new OcrImageInput(@"example.png");
// Perform OCR
OcrResult result = ocrTesseract.Read(imageInput);

// Output extracted text to console
Console.WriteLine(result.Text);
' Example code for reading multi-language image with IronOCR
Imports IronOcr

' Initialize IronTesseract OCR engine
Private Ocr = New IronTesseract()

Imports System

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Set primary language to Hindi
ocrTesseract.Language = OcrLanguage.Russian
ocrTesseract.AddSecondaryLanguage(OcrLanguage.Japanese)

' Add image
Dim imageInput = New OcrImageInput("example.png")
' Perform OCR
Dim result As OcrResult = ocrTesseract.Read(imageInput)

' Output extracted text to console
Console.WriteLine(result.Text)
$vbLabelText   $csharpLabel

If you do this right, you can expect results like the ones below.

Russian and Japanese

Conclusion

In brief, IronOCR, backed by the powerful Tesseract engine, excels at extracting text from documents in multiple languages. It's an indispensable tool for handling the complexities of reading text in many languages, offering developers and curious minds a versatile solution. Whether you're processing PDFs with text in various languages or working with multilingual content in images, IronOCR simplifies the task of recognizing and extracting text in multiple languages.

Preguntas Frecuentes

¿Cómo puedo usar múltiples idiomas en el procesamiento OCR?

Para usar múltiples idiomas en el procesamiento OCR con IronOCR, descargue la biblioteca de NuGet, prepare su documento, instale paquetes de idioma adicionales y use el método AddSecondaryLanguage para habilitar otros idiomas.

¿Cómo extraigo texto de un PDF multilingüe?

Puede extraer texto de un PDF multilingüe inicializando el motor de OCR IronTesseract, configurando el idioma principal, agregando idiomas secundarios usando el método AddSecondaryLanguage y procesando el PDF para leer su contenido.

¿Es posible reconocer texto en varios idiomas dentro de una imagen?

Sí, con IronOCR, puede reconocer texto en varios idiomas dentro de una imagen estableciendo el idioma principal y agregando idiomas secundarios al motor OCR antes de procesar la imagen.

¿Cómo afecta la adición de múltiples idiomas al rendimiento del OCR?

Agregar múltiples idiomas en IronOCR puede impactar la velocidad y el rendimiento del proceso de OCR. El orden de los idiomas añadidos determina su prioridad, siendo el primer idioma añadido el que tiene mayor prioridad.

¿Cómo puedo cambiar el idioma predeterminado en IronOCR?

Puede cambiar el idioma predeterminado en IronOCR configurando la propiedad Language al idioma deseado antes de procesar sus documentos o imágenes.

¿Cuántos paquetes de idioma soporta IronOCR?

IronOCR soporta aproximadamente 125 paquetes de idioma, aunque solo el paquete de idioma en inglés está instalado por defecto. Los paquetes de idiomas adicionales se pueden descargar via NuGet.

¿Cómo instalo paquetes de idioma adicionales en IronOCR?

Para instalar paquetes de idioma adicionales en IronOCR, use el Administrador de Paquetes NuGet para descargar los paquetes de idioma deseados e inclúyalos en su proyecto.

¿Puede IronOCR leer texto en idiomas con diferentes escrituras?

Sí, IronOCR puede leer texto en varios idiomas con diferentes escrituras utilizando el motor Tesseract y habilitando los paquetes de idioma relevantes.

¿Cuál es el beneficio de usar IronOCR para contenido multilingüe?

IronOCR proporciona una solución versátil para reconocer y extraer texto de contenido multilingüe, lo que lo hace ideal para desarrolladores que manejan documentos o imágenes que contienen texto en múltiples idiomas.

Kannaopat Udonpant
Ingeniero de Software
Antes de convertirse en Ingeniero de Software, Kannapat completó un doctorado en Recursos Ambientales de la Universidad de Hokkaido en Japón. Mientras perseguía su grado, Kannapat también se convirtió en miembro del Laboratorio de Robótica de Vehículos, que es parte del Departamento de Ingeniería ...
Leer más
Revisado por
Jeff Fritz
Jeffrey T. Fritz
Gerente Principal de Programas - Equipo de la Comunidad .NET
Jeff también es Gerente Principal de Programas para los equipos de .NET y Visual Studio. Es el productor ejecutivo de la serie de conferencias virtuales .NET Conf y anfitrión de 'Fritz and Friends', una transmisión en vivo para desarrolladores que se emite dos veces a la semana donde habla sobre tecnología y escribe código junto con la audiencia. Jeff escribe talleres, presentaciones, y planifica contenido para los eventos de desarrolladores más importantes de Microsoft, incluyendo Microsoft Build, Microsoft Ignite, .NET Conf y la Cumbre de Microsoft MVP.
¿Listo para empezar?
Nuget Descargas 5,044,537 | Versión: 2025.11 recién lanzado