如何以 IronOCR 作為 C# 中 Tesseract OCR 的替代方案
想在 C# 應用程式中實現光學字元辨識嗎? 雖然 Google Tesseract 提供免費的 OCR 解決方案,但許多開發者都難以應對其複雜的設定、在真實文件上的有限準確性以及具有挑戰性的 C++ 互通性要求。 本指南顯示如何使用IronOCR增強的Tesseract實現來達到高OCR準確性——一個原生C#程式庫,消除了安裝的麻煩並提供卓越的結果。
無論您是從掃描文件中提取文字、處理發票還是建立文件自動化系統,您都將學會如何在幾分鐘內而不是幾週內實現可用於生產的 OCR。
快速入門:使用 IronTesseract 進行單行 OCR 處理使用IronOCR最簡單的API在幾秒鐘內抓取文字。 本範例顯示如何通過單行程式碼呼叫IronTesseract,將圖像提供給它,然後獲得識別的文字——簡單無煩,僅得解。
-
1使用 IronOCR 安裝 NuGet Package Manager
-
2複製並運行這段程式碼。
string text = new IronTesseract().Read("image.png").Text;Dim text As String = New IronTesseract().Read("image.png").TextDim text As String = New IronTesseract().Read("image.png").Text -
3部署到您的生產環境進行測試
立即在您的項目中開始使用 IronOCR,並使用 免費試用
最小工作流程(5 個步驟)
- 透過NuGet套件管理器安裝增強版Tesseract OCR程式庫
- 配置影像預處理以獲得最佳文字辨識效果
- 處理多種文件格式,包括PDF和多幀TIFF
- 擷取具有字元級準確度指標的結構化資料
- 無需原生依賴即可跨平台部署
本文全面概述了 IronOCR 的 Tesseract C# 實現,重點介紹了其平台相容性、支援的格式以及高級處理能力。
如何用最少的代碼從圖像中提取文字於C#?
以下範例示範如何僅使用幾行程式碼在 .NET 應用程式中實作 OCR 功能。 與普通的 Tesseract 不同,這種方法可以自動處理影像預處理,即使掃描結果不完美也能提供準確的結果。
使用NuGet套件管理器將IronOCR NuGet套件安裝到您的Visual Studio解決方案中。
using IronOcr;
using System;
var ocr = new IronTesseract();
using var input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\example.tiff", pageindices);
input.DeNoise(); //fixes digital noise
input.Deskew(); //fixes rotation and perspective
// there are dozens more filters, but most users wont need them
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
using System;
var ocr = new IronTesseract();
using var input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\example.tiff", pageindices);
input.DeNoise(); //fixes digital noise
input.Deskew(); //fixes rotation and perspective
// there are dozens more filters, but most users wont need them
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Imports System
Private ocr = New IronTesseract()
Private input = New OcrInput()
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\example.tiff", pageindices)
input.DeNoise() 'fixes digital noise
input.Deskew() 'fixes rotation and perspective
' there are dozens more filters, but most users wont need them
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Imports System
Private ocr = New IronTesseract()
Private input = New OcrInput()
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\example.tiff", pageindices)
input.DeNoise() 'fixes digital noise
input.Deskew() 'fixes rotation and perspective
' there are dozens more filters, but most users wont need them
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)這段程式碼展示了 IronOCR 簡化 API 的強大功能。 IronTesseract 類別提供 Tesseract 5 的管理包裝,消除了複雜的 C++ 互操作的需求。OcrInput 類別支援載入多種圖像格式和頁面,而可選的預處理方法(DeNoise() 和 Deskew())可以大大提高真實文件的準確性。
除基本文本提取外,OcrResult物件提供豐富的結構化數據,包括字級信心分數、字元位置和文件結構,從而實現如可搜尋PDF創建和精確文本定位跟蹤等高級功能。
Tesseract 和 IronOCR 在安裝上有哪些主要差異?
使用 Tesseract 引擎和 .NET 進行 OCR
傳統 C# 中的 Tesseract 整合需要管理 C++ 函式庫,這帶來了一些挑戰。
開發人員必須處理特定於平台的二進位文件,確保 Visual C++ 運行時安裝,並管理 32/64 位元相容性問題。 安裝過程通常需要手動編譯 Tesseract 和 Leptonica 函式庫,特別是對於最新的 Tesseract 5 版本,這些版本並非為 Windows 編譯而設計。
在 Azure、Docker 或 Linux 等環境中,權限和相依性差異很大,因此跨平台部署會變得特別棘手。
IronOCR Tesseract適用於.NET
IronOCR 透過 NuGet 分發的單一託管 .NET 程式庫,簡化了安裝流程:
沒有原生 DLL,沒有 C++ 執行時,沒有平台特定的配置。 所有功能均以純託管程式碼形式運行,並自動解決依賴關係。
該庫與以下庫完全相容:
- .NET Framework 4.6.2 及更高版本
- .NET Standard 2.0及以上(包括.NET 8, 9和10)
這種方法確保在 Windows、macOS、Linux、Azure、AWS Lambda、Docker 容器,甚至 Xamarin 行動應用程式中保持一致的行為。
最新OCR引擎版本在.NET開發的比較情況如何?
Google Tesseract with C#
Tesseract 5 雖然功能強大,但對 Windows 開發人員來說卻帶來了巨大的挑戰。
最新版本需要使用 MinGW 進行交叉編譯,而 MinGW 很少能產生可用的 Windows 二進位。 GitHub 上的免費 C# 封裝庫通常比最新的 Tesseract 版本落後數年,缺少關鍵的改進和錯誤修復。 由於這些編譯障礙,開發人員經常使用過時的 Tesseract 3.x 或 4.x 版本。
IronOCR Tesseract適用於.NET
IronOCR附帶了一個專為.NET優化的自訂Tesseract 5引擎。
此實作方案包含效能增強功能,例如原生多執行緒支援、自動影像預處理以及高效處理大型文件。 定期更新可確保與最新的 .NET 版本相容,同時保持向後相容性。
本程式庫還透過專用的NuGet套件提供廣泛的語言支援,使其能夠輕鬆加入超過127種語言的OCR功能,而無需管理外部字典檔。
Google Cloud OCR 比較
雖然Google Cloud Vision OCR提供高準確性,但它需要網路連接,會產生每次請求的費用,並對於敏感文件引發數據隱私問題。 IronOCR 可提供與本地處理相當的精度,使其成為需要資料安全或離線功能的應用的理想選擇。
使用不同的方法可以達到怎樣的OCR準確率?
在 .NET 專案中使用 Google Tesseract
Raw Tesseract 擅長讀取高解析度、完美對齊的文字,但難以處理實際文件。
掃描的頁面、照片或低解析度影像如果不經過大量預處理,通常會產生亂碼輸出。 要達到可接受的精確度,通常需要使用 ImageMagick 或類似工具的自訂影像處理流程,這會增加每種文件類型的數週開發時間。
常見的準確性問題包括:
- 讀錯傾斜文件上的字符
- 在低DPI掃描上徹底失敗
- 混合使用不同字體或版面時效能不佳
- 無法處理背景噪音或浮水印
.NET 專案中的 IronOCR Tesseract
IronOCR的增強版實現可在典型的商務文件上提供高準確性,而無需人工預處理:
using IronOcr;
using System;
// Create an instance of the IronTesseract class for OCR processing
var ocr = new IronTesseract();
// Create an OcrInput object to load and preprocess images
using var input = new OcrInput();
// Specify which pages to extract from multi-page documents
var pageIndices = new int[] { 1, 2 };
// Load specific frames from a TIFF file
// IronOCR automatically detects and handles various image formats
input.LoadImageFrames(@"img\example.tiff", pageIndices);
// Apply automatic image enhancement filters
// These filters dramatically improve accuracy on imperfect scans
input.DeNoise(); // Removes digital artifacts and speckles
input.Deskew(); // Corrects rotation up to 15 degrees
// Perform OCR with enhanced accuracy algorithms
OcrResult result = ocr.Read(input);
// Access the extracted text with confidence metrics
Console.WriteLine(result.Text);
// Additional accuracy features available:
// - result.Confidence: Overall accuracy percentage
// - result.Pages[0].Words: Word-level confidence scores
// - result.Blocks: Structured document layout analysisusing IronOcr;
using System;
// Create an instance of the IronTesseract class for OCR processing
var ocr = new IronTesseract();
// Create an OcrInput object to load and preprocess images
using var input = new OcrInput();
// Specify which pages to extract from multi-page documents
var pageIndices = new int[] { 1, 2 };
// Load specific frames from a TIFF file
// IronOCR automatically detects and handles various image formats
input.LoadImageFrames(@"img\example.tiff", pageIndices);
// Apply automatic image enhancement filters
// These filters dramatically improve accuracy on imperfect scans
input.DeNoise(); // Removes digital artifacts and speckles
input.Deskew(); // Corrects rotation up to 15 degrees
// Perform OCR with enhanced accuracy algorithms
OcrResult result = ocr.Read(input);
// Access the extracted text with confidence metrics
Console.WriteLine(result.Text);
// Additional accuracy features available:
// - result.Confidence: Overall accuracy percentage
// - result.Pages[0].Words: Word-level confidence scores
// - result.Blocks: Structured document layout analysisImports IronOcr
Imports System
' Create an instance of the IronTesseract class for OCR processing
Private ocr = New IronTesseract()
' Create an OcrInput object to load and preprocess images
Private input = New OcrInput()
' Specify which pages to extract from multi-page documents
Private pageIndices = New Integer() { 1, 2 }
' Load specific frames from a TIFF file
' IronOCR automatically detects and handles various image formats
input.LoadImageFrames("img\example.tiff", pageIndices)
' Apply automatic image enhancement filters
' These filters dramatically improve accuracy on imperfect scans
input.DeNoise() ' Removes digital artifacts and speckles
input.Deskew() ' Corrects rotation up to 15 degrees
' Perform OCR with enhanced accuracy algorithms
Dim result As OcrResult = ocr.Read(input)
' Access the extracted text with confidence metrics
Console.WriteLine(result.Text)
' Additional accuracy features available:
' - result.Confidence: Overall accuracy percentage
' - result.Pages[0].Words: Word-level confidence scores
' - result.Blocks: Structured document layout analysisImports IronOcr
Imports System
' Create an instance of the IronTesseract class for OCR processing
Private ocr = New IronTesseract()
' Create an OcrInput object to load and preprocess images
Private input = New OcrInput()
' Specify which pages to extract from multi-page documents
Private pageIndices = New Integer() { 1, 2 }
' Load specific frames from a TIFF file
' IronOCR automatically detects and handles various image formats
input.LoadImageFrames("img\example.tiff", pageIndices)
' Apply automatic image enhancement filters
' These filters dramatically improve accuracy on imperfect scans
input.DeNoise() ' Removes digital artifacts and speckles
input.Deskew() ' Corrects rotation up to 15 degrees
' Perform OCR with enhanced accuracy algorithms
Dim result As OcrResult = ocr.Read(input)
' Access the extracted text with confidence metrics
Console.WriteLine(result.Text)
' Additional accuracy features available:
' - result.Confidence: Overall accuracy percentage
' - result.Pages[0].Words: Word-level confidence scores
' - result.Blocks: Structured document layout analysis自動預處理過濾器可以處理常見的文件品質問題,否則這些問題需要人工幹預。 DeNoise() 方法去除掃描中的數位浮水印,Deskew() 則矯正文件旋轉,這兩者對於維護高度精確性至關重要。
進階使用者可以透過使用自訂配置進一步優化準確度,包括字元白名單、區域特定處理和針對特定行業術語的專用語言模型。
OCR處理支援哪些影像格式和來源?
.NET 中的 Google Tesseract
原生 Tesseract 只接受 Leptonica PIX 格式——一種非託管的 C++ 指針,在 C# 中處理起來很困難。
將 .NET 映像轉換為 PIX 格式需要謹慎的記憶體管理,以防止記憶體洩漏。 支援 PDF 和多頁 TIFF 需要額外的程式庫,而這些程式庫本身也存在相容性問題。 許多實作方案在基本格式轉換方面存在困難,限制了其實際可用性。
IronOCR影像相容性
IronOCR 提供全面的格式支援和自動轉換功能:
- PDF 文件(包括受密碼保護的文件)
- 多幀 TIFF 文件
- 標準格式:JPEG、PNG、GIF、BMP
- 高級格式:JPEG2000、WBMP
- .NET 類型:
System.Drawing.Image,System.Drawing.Bitmap - 資料來源:流、位元組數組、檔案路徑
- 直接掃描器整合
全面格式支援範例
using IronOcr;
var text = new IronTesseract().Read("img.png").Text;using IronOcr;
var text = new IronTesseract().Read("img.png").Text;Imports IronOcr
Private text = (New IronTesseract()).Read("img.png").TextImports IronOcr
Private text = (New IronTesseract()).Read("img.png").Text這種統一的文檔載入方法消除了特定於格式的程式碼。 無論是處理掃描的 TIFF 檔案、數位 PDF 檔案或智慧型手機照片,同一個 API 都能處理所有場景。 OcrInput 類別智能管理記憶體並提供一致的結果,無論來源格式如何。
對於專業情景,IronOCR也支援從相同文件中讀取條碼和QR碼,從而在單次處理中實現全方面的文件數據提取。
OCR在實際應用上的表現表現如何?
免費 Google Tesseract 效能
Vanilla Tesseract 可以對與訓練資料相符的預處理高解析度影像提供可接受的速度。
然而,實際表現往往令人失望。 當 Tesseract 處理影像品質不佳時,處理掃描文件的單頁可能需要 10-30 秒。 單執行緒架構會成為批次的瓶頸,並且隨著影像尺寸增加,記憶體使用量可能會呈螺旋式上升。
IronOCR Tesseract 庫效能
IronOCR 為生產工作負載實施智慧效能最佳化:
using IronOcr;
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.Arabic;
using var input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageindices);
// Add image filters if needed
// In this case, even thought input is very low quality
// IronTesseract can read what conventional Tesseract cannot.
var result = ocr.Read(input);
// Console can't print Arabic on Windows easily.
// Let's save to disk instead.
result.SaveAsTextFile("arabic.txt");using IronOcr;
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.Arabic;
using var input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageindices);
// Add image filters if needed
// In this case, even thought input is very low quality
// IronTesseract can read what conventional Tesseract cannot.
var result = ocr.Read(input);
// Console can't print Arabic on Windows easily.
// Let's save to disk instead.
result.SaveAsTextFile("arabic.txt");Imports IronOcr
Private ocr = New IronTesseract()
ocr.Language = OcrLanguage.Arabic
Dim input = New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageindices)
' Add image filters if needed
' In this case, even thought input is very low quality
' IronTesseract can read what conventional Tesseract cannot.
Dim result = ocr.Read(input)
' Console can't print Arabic on Windows easily.
' Let's save to disk instead.
result.SaveAsTextFile("arabic.txt")Imports IronOcr
Private ocr = New IronTesseract()
ocr.Language = OcrLanguage.Arabic
Dim input = New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageindices)
' Add image filters if needed
' In this case, even thought input is very low quality
' IronTesseract can read what conventional Tesseract cannot.
Dim result = ocr.Read(input)
' Console can't print Arabic on Windows easily.
' Let's save to disk instead.
result.SaveAsTextFile("arabic.txt")這些優化措施證明了 IronOCR 已具備量產能力。 BlackListCharacters配置單獨就可以在不需要特殊字元時提高速度。 快速語言包為大批量處理提供了極佳的平衡,在這種處理中,完美的準確性並非至關重要。
對於企業應用,IronOCR的多執行緒支援可使多個文件同時處理,改善在現代多核心系統上的吞吐量,與單執行緒的Tesseract相比。
Tesseract 和 IronOCR 的 API 設計有何不同?
在 .NET 中使用 Google Tesseract OCR
將原始 Tesseract 整合到 C# 應用程式中面臨兩種具有挑戰性的選擇:
- Interop包裝器:通常過時、文件不足且容易記憶體洩漏
- 命令行執行:難以部署,受到安全政策阻撓,錯誤處理不佳
這兩種方法在雲端環境、Web應用程式或跨平台部署中都無法可靠地運作。 缺乏合適的 .NET 整合意味著要花費更多時間與工具作鬥爭,而不是解決業務問題。
IronOCR Tesseract OCR 函式庫,適用於 .NET
IronOCR 提供了一個完全託管、直覺的 API,專為 .NET 開發人員設計:
最簡實現
using IronOcr;
// For the Chinese Language Pack:
// PM> Install IronOcr.Languages.ChineseSimplified
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;
ocr.AddSecondaryLanguage(OcrLanguage.English);
// We can add any number of languages
using var input = new OcrInput();
input.LoadPdf("multi-language.pdf");
var result = ocr.Read(input);
result.SaveAsTextFile("results.txt");using IronOcr;
// For the Chinese Language Pack:
// PM> Install IronOcr.Languages.ChineseSimplified
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;
ocr.AddSecondaryLanguage(OcrLanguage.English);
// We can add any number of languages
using var input = new OcrInput();
input.LoadPdf("multi-language.pdf");
var result = ocr.Read(input);
result.SaveAsTextFile("results.txt");Imports IronOcr
' For the Chinese Language Pack:
' PM> Install IronOcr.Languages.ChineseSimplified
Private ocr = New IronTesseract()
ocr.Language = OcrLanguage.ChineseSimplified
ocr.AddSecondaryLanguage(OcrLanguage.English)
' We can add any number of languages
Dim input = New OcrInput()
input.LoadPdf("multi-language.pdf")
Dim result = ocr.Read(input)
result.SaveAsTextFile("results.txt")Imports IronOcr
' For the Chinese Language Pack:
' PM> Install IronOcr.Languages.ChineseSimplified
Private ocr = New IronTesseract()
ocr.Language = OcrLanguage.ChineseSimplified
ocr.AddSecondaryLanguage(OcrLanguage.English)
' We can add any number of languages
Dim input = New OcrInput()
input.LoadPdf("multi-language.pdf")
Dim result = ocr.Read(input)
result.SaveAsTextFile("results.txt")這個有效的API消除了傳統Tesseract整合的複雜性。 每個方法都包含詳細的XML文件,便於您直接在IDE中探索功能。廣泛的API文件提供每個功能的詳細範例。
經驗豐富的工程師提供的專業支援確保您不會在實施細節上遇到困難。 該程式庫會定期更新,在保持與最新 .NET 版本相容的同時,根據開發者的回饋添加新功能。
支援哪些平台和部署場景?
Google Tesseract + Interop for .NET
跨平台 Tesseract 部署需要針對特定平台進行建置和配置。
每個目標環境都需要不同的二進位檔案、執行時間依賴項和權限。 Docker容器需要仔細選擇基礎映像。 由於缺少 Visual C++ 運行時,Azure 部署經常失敗。 Linux相容性取決於具體的發行版和軟體包可用性。
IronOCR Tesseract .NET OCR庫
IronOCR 提供真正的「一次寫入,隨處部署」功能:
應用類型:
- 桌面應用程式(WPF、WinForms、控制台)
- Web 應用程式(ASP.NET Core、Blazor)
- 雲端服務(Azure Functions、AWS Lambda)
- 行動應用程式(透過 Xamarin)
- 微服務(Docker、Kubernetes)
平台支援:
- Windows(7、8、10、11、伺服器版本)
- macOS (Intel 和 Apple Silicon)
- Linux(Ubuntu、Debian、CentOS、Alpine)
- Docker 容器(官方基礎映像)
- 雲平台(Azure, AWS, Google Cloud)
.NET 相容性:
.NET Framework 4.6.2及以上.NET Standard 2.0及以上(包括.NET 8、9和10)- Mono 框架
- Xamarin.Mac
該庫在內部處理平台差異,從而在所有環境下提供一致的結果。 部署指南涵蓋特定情景,包括容器化、無伺服器函數和高可用性配置。
多國語言OCR功能比較如何?
Google Tesseract 語言支援
在 Tesseract 中管理語言需要下載和維護 tessdata 檔案 - 所有語言大約需要 4GB。
資料夾結構必須精確,環境變數必須配置正確,且路徑在運行時必須可存取。語言切換需要存取檔案系統,這使得在受限環境中部署變得複雜。 Tesseract 二進位檔案和語言檔案之間的版本不匹配會導致難以理解的錯誤。
IronOCR語言管理
IronOCR 透過 NuGet 套件管理革新了語言支援:
阿拉伯語 OCR 範例
using IronOcr;
// Configure IronTesseract for Arabic text recognition
var ocr = new IronTesseract
{
// Set primary language to Arabic
// Automatically handles right-to-left text
Language = OcrLanguage.Arabic
};
// Load Arabic documents for processing
using var input = new OcrInput();
var pageIndices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageIndices);
// IronOCR includes specialized preprocessing for Arabic scripts
// Handles cursive text and diacritical marks automatically
// Perform OCR with language-specific optimizations
var result = ocr.Read(input);
// Save results with proper Unicode encoding
// Preserves Arabic text formatting and direction
result.SaveAsTextFile("arabic.txt");
// Advanced Arabic features:
// - Mixed Arabic/English document support
// - Automatic number conversion (Eastern/Western Arabic)
// - Font-specific optimization for common Arabic typefacesusing IronOcr;
// Configure IronTesseract for Arabic text recognition
var ocr = new IronTesseract
{
// Set primary language to Arabic
// Automatically handles right-to-left text
Language = OcrLanguage.Arabic
};
// Load Arabic documents for processing
using var input = new OcrInput();
var pageIndices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageIndices);
// IronOCR includes specialized preprocessing for Arabic scripts
// Handles cursive text and diacritical marks automatically
// Perform OCR with language-specific optimizations
var result = ocr.Read(input);
// Save results with proper Unicode encoding
// Preserves Arabic text formatting and direction
result.SaveAsTextFile("arabic.txt");
// Advanced Arabic features:
// - Mixed Arabic/English document support
// - Automatic number conversion (Eastern/Western Arabic)
// - Font-specific optimization for common Arabic typefacesImports IronOcr
' Configure IronTesseract for Arabic text recognition
Private ocr = New IronTesseract With {.Language = OcrLanguage.Arabic}
' Load Arabic documents for processing
Private input = New OcrInput()
Private pageIndices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageIndices)
' IronOCR includes specialized preprocessing for Arabic scripts
' Handles cursive text and diacritical marks automatically
' Perform OCR with language-specific optimizations
Dim result = ocr.Read(input)
' Save results with proper Unicode encoding
' Preserves Arabic text formatting and direction
result.SaveAsTextFile("arabic.txt")
' Advanced Arabic features:
' - Mixed Arabic/English document support
' - Automatic number conversion (Eastern/Western Arabic)
' - Font-specific optimization for common Arabic typefacesImports IronOcr
' Configure IronTesseract for Arabic text recognition
Private ocr = New IronTesseract With {.Language = OcrLanguage.Arabic}
' Load Arabic documents for processing
Private input = New OcrInput()
Private pageIndices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageIndices)
' IronOCR includes specialized preprocessing for Arabic scripts
' Handles cursive text and diacritical marks automatically
' Perform OCR with language-specific optimizations
Dim result = ocr.Read(input)
' Save results with proper Unicode encoding
' Preserves Arabic text formatting and direction
result.SaveAsTextFile("arabic.txt")
' Advanced Arabic features:
' - Mixed Arabic/English document support
' - Automatic number conversion (Eastern/Western Arabic)
' - Font-specific optimization for common Arabic typefaces多語言文件處理
using IronOcr;
// Install language packs via NuGet:
// PM> Install-Package IronOcr.Languages.ChineseSimplified
// Configure multi-language OCR
var ocr = new IronTesseract();
// Set primary language for majority content
ocr.Language = OcrLanguage.ChineseSimplified;
// Add secondary language for mixed content
// Perfect for documents with Chinese text and English metadata
ocr.AddSecondaryLanguage(OcrLanguage.English);
// Process multi-language PDFs efficiently
using var input = new OcrInput();
input.LoadPdf("multi-language.pdf");
// IronOCR automatically detects and switches between languages
// Maintains high accuracy across language boundaries
var result = ocr.Read(input);
// Export preserves all languages correctly
result.SaveAsTextFile("results.txt");
// Supported scenarios:
// - Technical documents with English terms in foreign text
// - Multilingual forms and applications
// - International business documents
// - Mixed-script content (Latin, CJK, Arabic, etc.)using IronOcr;
// Install language packs via NuGet:
// PM> Install-Package IronOcr.Languages.ChineseSimplified
// Configure multi-language OCR
var ocr = new IronTesseract();
// Set primary language for majority content
ocr.Language = OcrLanguage.ChineseSimplified;
// Add secondary language for mixed content
// Perfect for documents with Chinese text and English metadata
ocr.AddSecondaryLanguage(OcrLanguage.English);
// Process multi-language PDFs efficiently
using var input = new OcrInput();
input.LoadPdf("multi-language.pdf");
// IronOCR automatically detects and switches between languages
// Maintains high accuracy across language boundaries
var result = ocr.Read(input);
// Export preserves all languages correctly
result.SaveAsTextFile("results.txt");
// Supported scenarios:
// - Technical documents with English terms in foreign text
// - Multilingual forms and applications
// - International business documents
// - Mixed-script content (Latin, CJK, Arabic, etc.)Imports IronOcr
' Install language packs via NuGet:
' PM> Install-Package IronOcr.Languages.ChineseSimplified
' Configure multi-language OCR
Private ocr = New IronTesseract()
' Set primary language for majority content
ocr.Language = OcrLanguage.ChineseSimplified
' Add secondary language for mixed content
' Perfect for documents with Chinese text and English metadata
ocr.AddSecondaryLanguage(OcrLanguage.English)
' Process multi-language PDFs efficiently
Dim input = New OcrInput()
input.LoadPdf("multi-language.pdf")
' IronOCR automatically detects and switches between languages
' Maintains high accuracy across language boundaries
Dim result = ocr.Read(input)
' Export preserves all languages correctly
result.SaveAsTextFile("results.txt")
' Supported scenarios:
' - Technical documents with English terms in foreign text
' - Multilingual forms and applications
' - International business documents
' - Mixed-script content (Latin, CJK, Arabic, etc.)Imports IronOcr
' Install language packs via NuGet:
' PM> Install-Package IronOcr.Languages.ChineseSimplified
' Configure multi-language OCR
Private ocr = New IronTesseract()
' Set primary language for majority content
ocr.Language = OcrLanguage.ChineseSimplified
' Add secondary language for mixed content
' Perfect for documents with Chinese text and English metadata
ocr.AddSecondaryLanguage(OcrLanguage.English)
' Process multi-language PDFs efficiently
Dim input = New OcrInput()
input.LoadPdf("multi-language.pdf")
' IronOCR automatically detects and switches between languages
' Maintains high accuracy across language boundaries
Dim result = ocr.Read(input)
' Export preserves all languages correctly
result.SaveAsTextFile("results.txt")
' Supported scenarios:
' - Technical documents with English terms in foreign text
' - Multilingual forms and applications
' - International business documents
' - Mixed-script content (Latin, CJK, Arabic, etc.)語言包系統支援超過127種語言,每種語言都針對特定的書寫體系和書寫系統進行優化。 透過 NuGet 安裝可確保版本相容性,並簡化跨不同環境的部署。
除了基本的OCR功能外,IronOCR還提供哪些其他功能?
IronOCR 的功能遠不止基本的文字擷取,它還具備企業級功能:
- 自動圖像分析:根據圖像特性智力配置處理過程
- 可搜尋PDF創建:將掃描文件轉換為完全可搜尋的PDF。 將
true作為第二個引數傳遞給SaveAsSearchablePdf()以應用主動 OCR 過濾器到輸出(新增於 v2025.5.11) - 高級PDF OCR:提取文本的同時保持文件的結構
- — 條碼和 QR Code 讀取:在同一過程中檢測和解碼條碼
- HTML導出:從OCR結果生成結構化HTML
- TIFF到PDF轉換:將多頁TIFF轉換為可搜尋的PDF
- 手寫英文OCR:原生英文手寫識別,於v2025.11.31新增——在處理手填表格和筆記方面優於原始Tesseract
- 方向檢測:
DetectPageOrientation()支援四個OrientationDetectionMode值 -Fast、Balanced、Detailed、ExtremeDetailed- 用於控制準確性/速度取捨(已新增於 v2025.8.6) - 支援多執行緒:同時處理多個文件
- 詳細結果分析:訪問具有信心分數的字元級數據
Scale()和EnhanceResolution()因v2025.12.3中的已知問題而與SaveAsSearchablePdf()不相容。所有其他過濾器都能正確輸出可搜索的PDF。OcrResult類提供對識別內容的細緻訪問,使得可實現複雜的後期處理和驗證工作流程。
您應該選擇哪種OCR解決方案來進行C#開發?
Google Tesseract for C# OCR
選擇香草色 Tesseract 的情況:
- 從事學術或研究專案
- 處理完美掃描的文檔,開發時間不受限制
- 建立概念驗證應用程式
- 成本是唯一考量
要做好應對重大整合挑戰和持續維護需求的準備。
IronOCR Tesseract OCR 函式庫,適用於 .NET Framework 和 Core
IronOCR是以下情況的最佳選擇:
- 需要可靠性的生產應用
- 具有真實世界文檔品質的項目
- 跨平台部署
- 時間緊迫的開發計劃
- 需要專業支援的應用
該庫透過縮短開發時間和提高複雜文件的準確性來收回成本。
如何在您的C#項目中開始進行專業OCR?
開始在 Visual Studio 專案中實現高精度 OCR:
或者直接下載IronOCR .NET DLL進行手動安裝。
體驗專業OCR的不同之處——今天就開始您的免費試用,加入數千家公司簡化其文件處理流程。
Iron Software 的 OCR 技術深受全球財富 500 強企業和政府機構的信賴,用於關鍵任務文件處理。
常見問題
在C#應用程式中使用IronOCR與Google Tesseract相比的主要優勢是什麼?
IronOCR提供Tesseract的原生C#實現,排除了複雜的設置和C++互操作性挑戰,同時提供增強的準確性和與.NET應用程式的輕鬆整合。
IronOCR 如何提高 OCR 結果的準確性?
IronOCR透過自動完成影像預處理步驟來增強準確性,如去噪和矯正斜率,並支援優化在現實世界文件上OCR性能的先進算法。
IronOCR 支援哪些平台?
IronOCR支援多種平台,包括Windows、macOS、Linux、Azure、AWS Lambda、Docker容器和Xamarin,確保跨平台兼容性。
IronOCR能有效處理PDF和多頁TIFF嗎?
是的,IronOCR能處理多個文件格式,如PDF和多頁TIFF,並內建支援複雜文件類型,超越標準影像格式。
IronOCR是否支援多語言OCR功能?
IronOCR支援超過127種語言,並提供專用的NuGet套件以便於整合,允許順暢地進行多語言文件的OCR處理。
IronOCR除了傳統的OCR之外還提供哪些其他功能?
IronOCR提供創建可搜尋PDF、條碼閱讀、HTML匯出、手寫英文的高級OCR以及帶有信心指標的詳細結果分析等功能。
IronOCR如何針對現實世界的文件處理進行優化?
IronOCR透過多執行緒支援和自動影像預處理等性能增強進行優化,確保即使在複雜文件上也具有高準確性和快速處理能力。
IronOCR的API設計與Tesseract相比有何不同?
IronOCR提供專為.NET開發者設計的完全託管且直觀的API,簡化整合流程並提供全面的文件和支援以促進快速實施。
IronOCR如何處理不同影像格式的OCR?
IronOCR自動管理JPEG、PNG、BMP等各種格式的影像轉換,並支援.NET類型,為所有影像處理需求提供一致的API。
為什麼IronOCR是C#中專業OCR解決方案的首選?
IronOCR因其易用性、可靠的功能集、跨平台兼容性及可靠的支援,在生產環境中成為專業OCR的理想選擇。
Jacob Mellor是Iron Software的首席技術官,也是開創C# PDF技術的前瞻性工程師。作為Iron Software核心代碼庫的原始開發者,他自公司成立以來就塑造了公司的產品架構,並與CEO Cameron Rimington將公司轉型為服務NASA、Tesla以及全球政府機構的50多人公司。
