C# 和 .NET 中的泰文OCR

Curtis Chau
Curtis Chau
Updated: 2026年5月9日
本文档的其他版本:

IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言的文本,包括泰语字母。

它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。

IronOcr.Languages.Thai 的内容

此软件包包含 96 种适用于 .NET 的 OCR 语言:

  • 泰语
  • 泰语Best
  • 泰语Fast
  • 泰语字母
  • 泰语字母Best
  • 泰语字母Fast

下载

泰语字母语言包[泰语]

安装

我们首先需要做的就是将我们的泰语字母OCR 包安装到您的 .NET 项目中。

PM > Install-Package IronOcr.Languages.Thai

代码示例

这段 C# 代码示例从图像或 PDF 文档中读取泰语字母文本。

// Ensure you have installed the IronOcr.Languages.Thai package via NuGet.
// Import the IronOcr namespace to work with IronOCR classes.
using IronOcr; 

class ThaiOcrExample
{
    static void Main()
    {
        // Create a new instance of IronTesseract for OCR processing
        var ocr = new IronTesseract();
        
        // Set the language to Thai for Optical Character Recognition
        ocr.Language = OcrLanguage.Thai;

        // Using the 'using' statement ensures that resources are properly disposed.
        using (var input = new OcrInput(@"images\Thai.png"))
        {
            // Perform OCR to read the text from the input image
            var result = ocr.Read(input);

            // Retrieve and store all recognized text from the image
            string allText = result.Text;

            // Optionally, you can output the text to console or log it as needed
            System.Console.WriteLine(allText);
        }
    }
}

在此示例中,我们从名为images文件夹中。 请务必将文件路径替换为您实际的图片位置。 OCR语言设置为泰文,使用OcrLanguage.Thai指定用于识别的泰文语言包。

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

阅读更多

准备开始了吗?

Nuget Downloads 6,357,159版本:2026.11刚刚发布