IronOCR 教程 Tesseract比较 How to Tesseract OCR in C# Alternatives with IronOCR Jacob Mellor 更新:2026年1月10日 下載 IronOCR NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 LLM副本 LLM副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 想在 C# 應用程式中實現光學字元辨識嗎? 雖然 Google Tesseract 提供免費的 OCR 解決方案,但許多開發者都難以應對其複雜的設定、在真實文件上的有限準確性以及具有挑戰性的 C++ 互通性要求。 本綜合指南向您展示如何使用 IronOCR 增強的 Tesseract 實作(原生 C# 函式庫,可消除安裝難題,同時提供卓越的結果)達到 99.8-100% 的 OCR 準確率。 無論您是從掃描文件中提取文字、處理發票還是建立文件自動化系統,您都將學會如何在幾分鐘內而不是幾週內實現可用於生產的 OCR。 快速入門:使用 IronTesseract 進行單行 OCR 使用 IronOCR 最簡單的 API,幾秒鐘即可抓取文字。 這個範例展示如何透過一行程式碼呼叫 IronTesseract,向其提供圖像,並獲取識別出的文字——簡單直接,結果立竿見影。 使用NuGet套件管理器安裝https://www.nuget.org/packages/IronOcr PM > Install-Package IronOcr 複製並運行這段程式碼。 string text = new IronTesseract().Read(new OcrInput("image.png")).Text; 部署到您的生產環境進行測試 今天就在您的專案中開始使用免費試用IronOCR Free 30 Day Trial ### 最簡工作流程(5個步驟) 透過NuGet套件管理器安裝增強型 Tesseract OCR 庫 配置影像預處理以獲得最佳文字辨識效果 處理多種文件格式,包括PDF和多幀TIFF 擷取具有字元級準確度指標的結構化數據 無需原生依賴即可跨平台部署 本文全面概述了 IronOCR 的 Tesseract C# 實現,重點介紹了其平台相容性、支援的格式以及高級處理能力。 如何使用最少的程式碼在 C# 中從圖像中提取文字? 以下範例示範如何僅使用幾行程式碼在.NET應用程式中實作 OCR 功能。 與普通的 Tesseract 不同,這種方法可以自動處理影像預處理,即使掃描結果不完美也能提供準確的結果。 使用NuGet套件管理器將IronOCR NuGet套件安裝到 Visual Studio 解決方案中。 using IronOcr; using System; // Initialize IronTesseract for performing OCR (Optical Character Recognition) var ocr = new IronTesseract { // Set the language for the OCR process to English Language = OcrLanguage.English }; // Create a new OCR input that can hold the images to be processed using var input = new OcrInput(); // Specify the page indices to be processed from the TIFF image var pageIndices = new int[] { 1, 2 }; // Load specific pages of the TIFF image into the OCR input object // Perfect for processing large multi-page documents efficiently input.LoadImageFrames(@"img\example.tiff", pageIndices); // Optional pre-processing steps (uncomment as needed) // input.DeNoise(); // Remove digital noise from scanned documents // input.Deskew(); // Automatically straighten tilted scans // Perform OCR on the provided input OcrResult result = ocr.Read(input); // Output the recognized text to the console Console.WriteLine(result.Text); // Note: The OcrResult object contains detailed information including: // - Individual words with confidence scores // - Character positions and bounding boxes // - Paragraph and line structure using IronOcr; using System; // Initialize IronTesseract for performing OCR (Optical Character Recognition) var ocr = new IronTesseract { // Set the language for the OCR process to English Language = OcrLanguage.English }; // Create a new OCR input that can hold the images to be processed using var input = new OcrInput(); // Specify the page indices to be processed from the TIFF image var pageIndices = new int[] { 1, 2 }; // Load specific pages of the TIFF image into the OCR input object // Perfect for processing large multi-page documents efficiently input.LoadImageFrames(@"img\example.tiff", pageIndices); // Optional pre-processing steps (uncomment as needed) // input.DeNoise(); // Remove digital noise from scanned documents // input.Deskew(); // Automatically straighten tilted scans // Perform OCR on the provided input OcrResult result = ocr.Read(input); // Output the recognized text to the console Console.WriteLine(result.Text); // Note: The OcrResult object contains detailed information including: // - Individual words with confidence scores // - Character positions and bounding boxes // - Paragraph and line structure $vbLabelText $csharpLabel 這段程式碼展示了 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 for .NET IronOCR透過NuGet分發的單一託管.NET庫,消除了安裝的複雜性: Install-Package IronOcr 沒有原生 DLL,沒有 C++ 執行時,沒有平台特定的配置。 所有功能均以純託管程式碼形式運行,並自動解決依賴關係。 該庫與以下庫完全相容: .NET Framework 4.6.2 及更高版本 .NET Standard 2.0 及更高版本(包括.NET 5、6、7、8、9 和 10) .NET Core 2.0 及更高版本 這種方法確保在 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 for .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 的增強版無需人工預處理,即可在典型商業文件上實現99.8-100% 的準確率: 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 analysis 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 analysis $vbLabelText $csharpLabel 自動預處理過濾器可以處理常見的文件品質問題,否則這些問題需要人工幹預。 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; using System; // Initialize IronTesseract for OCR operations var ocr = new IronTesseract(); // Create an OcrInput container for multiple sources using var input = new OcrInput(); // Load password-protected PDFs seamlessly // IronOCR handles PDF rendering internally input.LoadPdf("example.pdf", "password"); // Process specific pages from multi-page TIFFs // Perfect for batch document processing var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("multi-frame.tiff", pageIndices); // Add individual images in any common format // Automatic format detection and conversion input.LoadImage("image1.png"); input.LoadImage("image2.jpeg"); // Process all loaded content in a single operation // Results maintain document structure and ordering var result = ocr.Read(input); // Extract text while preserving document layout Console.WriteLine(result.Text); // Advanced features for complex documents: // - Extract images from specific PDF pages // - Process only certain regions of images // - Maintain reading order across mixed formats using IronOcr; using System; // Initialize IronTesseract for OCR operations var ocr = new IronTesseract(); // Create an OcrInput container for multiple sources using var input = new OcrInput(); // Load password-protected PDFs seamlessly // IronOCR handles PDF rendering internally input.LoadPdf("example.pdf", "password"); // Process specific pages from multi-page TIFFs // Perfect for batch document processing var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("multi-frame.tiff", pageIndices); // Add individual images in any common format // Automatic format detection and conversion input.LoadImage("image1.png"); input.LoadImage("image2.jpeg"); // Process all loaded content in a single operation // Results maintain document structure and ordering var result = ocr.Read(input); // Extract text while preserving document layout Console.WriteLine(result.Text); // Advanced features for complex documents: // - Extract images from specific PDF pages // - Process only certain regions of images // - Maintain reading order across mixed formats $vbLabelText $csharpLabel 這種統一的文檔載入方法消除了特定於格式的程式碼。 無論是處理掃描的 TIFF 檔案、數位 PDF 檔案或智慧型手機照片,同一個 API 都能處理所有場景。 OcrInput 類別能夠智慧地管理內存,並且無論來源格式如何,都能提供一致的結果。 對於特殊場景, IronOCR還支援從同一文件中讀取條碼和二維碼,從而能夠一次提取全面的文檔資料。 OCR在實際應用上的表現表現如何? 免費 Google Tesseract 效能 Vanilla Tesseract 可以對與訓練資料相符的預處理高解析度影像提供可接受的速度。 然而,實際表現往往令人失望。 當 Tesseract 處理影像品質不佳時,處理掃描文件的單頁可能需要 10-30 秒。 單執行緒架構會成為批次的瓶頸,並且隨著影像尺寸增加,記憶體使用量可能會呈螺旋式上升。 IronOCR Tesseract 庫效能 IronOCR為生產工作負載實施智慧效能最佳化: using IronOcr; using System; // Configure IronTesseract for optimal performance var ocr = new IronTesseract(); // Performance optimization: disable unnecessary character recognition // Speeds up processing by 20-30% when special characters aren't needed ocr.Configuration.BlackListCharacters = "~`$#^*_}{][|\\@¢©«»°±·×-–—''""•…′″€™←↑→↓↔⇄⇒∅∼≅≈≠≤≥≪≫⌁⌘○◔◑◕●"; // Use automatic page segmentation for faster processing // Adapts to document layout without manual configuration ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto; // Disable barcode scanning when not needed // Eliminates unnecessary processing overhead ocr.Configuration.ReadBarCodes = false; // Switch to fast language pack for speed-critical applications // Trades minimal accuracy for 40% performance improvement ocr.Language = OcrLanguage.EnglishFast; // Load and process documents efficiently using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames(@"img\Potter.tiff", pageIndices); // Multi-threaded processing utilizes all CPU cores // Automatically scales based on system capabilities var result = ocr.Read(input); Console.WriteLine(result.Text); // Performance monitoring capabilities: // - result.TimeToRead: Processing duration // - result.InputDetails: Image analysis metrics // - Memory-efficient streaming for large documents using IronOcr; using System; // Configure IronTesseract for optimal performance var ocr = new IronTesseract(); // Performance optimization: disable unnecessary character recognition // Speeds up processing by 20-30% when special characters aren't needed ocr.Configuration.BlackListCharacters = "~`$#^*_}{][|\\@¢©«»°±·×-–—''""•…′″€™←↑→↓↔⇄⇒∅∼≅≈≠≤≥≪≫⌁⌘○◔◑◕●"; // Use automatic page segmentation for faster processing // Adapts to document layout without manual configuration ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto; // Disable barcode scanning when not needed // Eliminates unnecessary processing overhead ocr.Configuration.ReadBarCodes = false; // Switch to fast language pack for speed-critical applications // Trades minimal accuracy for 40% performance improvement ocr.Language = OcrLanguage.EnglishFast; // Load and process documents efficiently using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames(@"img\Potter.tiff", pageIndices); // Multi-threaded processing utilizes all CPU cores // Automatically scales based on system capabilities var result = ocr.Read(input); Console.WriteLine(result.Text); // Performance monitoring capabilities: // - result.TimeToRead: Processing duration // - result.InputDetails: Image analysis metrics // - Memory-efficient streaming for large documents $vbLabelText $csharpLabel 這些優化措施證明了 IronOCR 已具備量產能力。 如果不需要特殊字符,僅使用 BlackListCharacters 配置就可以提高 20-30% 的速度。 快速語言包為大批量處理提供了極佳的平衡,在這種處理中,完美的準確性並非至關重要。 對於企業應用而言,IronOCR 的多線程支援能夠同時處理多個文檔,與單線程 Tesseract 相比,在現代多核心系統上可實現 4-8 倍的吞吐量提升。 Tesseract 和IronOCR的 API 設計有何不同? 在.NET中使用 Google Tesseract OCR 將原始 Tesseract 整合到 C# 應用程式中面臨兩種具有挑戰性的選擇: -互通封裝器:通常過時、文件不完善且容易出現記憶體洩漏 -命令列執行:部署困難,受安全性原則限制,錯誤處理能力差。 這兩種方法在雲端環境、Web應用程式或跨平台部署中都無法可靠地運作。 缺乏合適的.NET整合意味著要花費更多時間與工具作鬥爭,而不是解決業務問題。 IronOCR Tesseract OCR 函式庫,適用於.NET IronOCR提供了一個完全託管、直覺的 API,專為.NET開發人員設計: 最簡實現 using IronOcr; // Initialize the OCR engine with full IntelliSense support var ocr = new IronTesseract(); // Process an image with automatic format detection // Handles JPEG, PNG, TIFF, PDF, and more var result = ocr.Read("img.png"); // Extract text with confidence metrics string extractedText = result.Text; Console.WriteLine(extractedText); // Rich API provides detailed results: // - result.Confidence: Overall accuracy percentage // - result.Pages: Page-by-page breakdown // - result.Paragraphs: Document structure // - result.Words: Individual word details // - result.Barcodes: Detected barcode values using IronOcr; // Initialize the OCR engine with full IntelliSense support var ocr = new IronTesseract(); // Process an image with automatic format detection // Handles JPEG, PNG, TIFF, PDF, and more var result = ocr.Read("img.png"); // Extract text with confidence metrics string extractedText = result.Text; Console.WriteLine(extractedText); // Rich API provides detailed results: // - result.Confidence: Overall accuracy percentage // - result.Pages: Page-by-page breakdown // - result.Paragraphs: Document structure // - result.Words: Individual word details // - result.Barcodes: Detected barcode values $vbLabelText $csharpLabel 這種簡化的 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 以上版本(含 9, & @@CODE-CODE-82--@) .NET Core 2.0 以上 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 typefaces 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 typefaces $vbLabelText $csharpLabel 多語言文件處理 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.) $vbLabelText $csharpLabel 語言包系統支援超過 127 種語言,每種語言都針對特定的腳本和書寫系統進行了最佳化。 透過NuGet安裝可確保版本相容性,並簡化跨不同環境的部署。 除了基本的OCR功能外, IronOCR還提供哪些其他功能? IronOCR 的功能遠不止基本的文字擷取,它還具備企業級功能: -自動影像分析:根據影像特徵智慧配置處理方案 -建立可搜尋的PDF :將掃描文件轉換為完全可搜尋的PDF文件 -進階PDF OCR :在保留文件結構的同時提取文本 條碼和二維碼讀取:一次掃描即可偵測和解碼條碼。 HTML匯出:根據OCR結果產生結構化HTML TIFF 轉 PDF 轉換:將多頁 TIFF 檔案轉換為可搜尋的 PDF 文件 支援多執行緒:可同時處理多個文檔 -詳細結果分析:存取具有置信度評分的角色級數據 OcrResult 類別提供對已識別內容的精細訪問,從而實現複雜的後處理和驗證工作流程。 C# 開發應該選擇哪一種 OCR 解決方案? Google Tesseract for C# OCR 選擇香草色 Tesseract 的情況: 參與學術或研究項目 處理完美掃描的文檔,開發時間不受限制 建立概念驗證應用程式 成本是唯一考慮因素。 做好應對重大整合挑戰和持續維護需求的準備。 IronOCR Tesseract OCR 函式庫,適用於.NET Framework和 Core IronOCR是以下情況的最佳選擇: 需要可靠性的生產應用 具有真實世界文檔品質的項目 跨平台部署 時間緊迫的開發計劃 需要專業支援的應用 該庫透過縮短開發時間和提高複雜文件的準確性來收回成本。 如何在 C# 專案中開始使用專業 OCR? 開始在 Visual Studio 專案中實現高精度 OCR: Install-Package IronOcr 或直接下載IronOCR .NET DLL進行手動安裝。 首先請參閱我們全面的入門指南,瀏覽程式碼範例,並在需要時獲得專業支援。 體驗專業 OCR 帶來的不同——立即開始免費試用,加入超過 10,000 家公司行列,在文件處理工作流程中實現 99.8% 以上的準確率。 Iron Software 的OCR 技術深受全球財富 500 強企業和政府機構的信賴,用於關鍵任務文件處理。 常見問題解答 我如何在C#應用程序中實現Tesseract OCR? 要在 C# 應用程序中實現 Tesseract OCR,您可以使用 IronOCR 中的 IronTesseract 类。通過命令 Install-Package IronOcr 使用 NuGet 安装,然後添加命名空间 using IronOcr;。使用 var ocr = new IronTesseract(); 實例化OCR引擎,并使用 var result = ocr.Read("image.png"); 從图像中提取文本。 使用 IronOCR 比傳统 Tesseract 有哪些好處? IronOCR 提供了多項优于傳统 Tesseract 的优势,包括無需本机依赖項的簡化部署、用于提高准确性的自動图像预處理和托管的 .NET 集成。它提供 PDF 和多語言支持等功能,可以通過 NuGet 易于安装,避免了原版 Tesseract 所需的复杂 C++ 互操作。 如何改善C#項目中的OCR准确性? 要改善C#項目中的OCR准确性,请使用IronOCR的自動图像增強功能。方法如 input.DeNoise() 和 input.Deskew() 帮助预處理图像,减少噪声和校正倾斜。此外,選择合適的語言設置并使用通過 OcrResult.Confidence 進行准确性验證的置信度指標。 我可以使用C#對PDF文檔执行OCR嗎? 是的,使用 IronOCR 的 OcrInput 类,您可以對 PDF 文檔执行 OCR。使用 input.LoadPdf("file.pdf", "password") 加载 PDF,并使用 var result = ocr.Read(input); 處理它。这允許在您的 C# 應用程序中直接提取文本和创建可搜索的 PDF。 我如何處理单個OCR文檔中的多种語言? IronOCR 允許在单個文檔中處理多种語言。使用 ocr.Language = OcrLanguage.English; 設置主要語言,并通過 ocr.AddSecondaryLanguage(OcrLanguage.Spanish); 添加辅助語言。这种灵活性對于包含混合語言或技術術语的文檔非常有利。 哪些平台支持 IronOCR? IronOCR 支持多种平台,包括 .NET Framework 4.6.2+,.NET Core 2.0+,.NET 5-10 和 .NET Standard 2.0+。它在 Windows、macOS 和 Linux 上運行,也可以在 Docker 容器、Azure Functions、AWS Lambda 和 Xamarin 移動應用中運行,提供在不同环境中的一致性能。 我如何优化C#中OCR處理的性能? 要优化C#中OCR處理的性能,利用IronOCR的功能,如通過 ocr.Configuration.ReadBarCodes = false; 禁用不必要的條形碼扫描,并選择更快的語言模型,如 ocr.Language = OcrLanguage.EnglishFast;。此外,利用多线程功能進行更快的批處理。 IronOCR支持哪些图像格式? IronOCR 支持多种图像格式,包括 PDF、TIFF、JPEG 和 PNG。使用 OcrInput 类通過 input.LoadImage("photo.jpg") 或 input.LoadPdf("file.pdf") 等方法加载图像。这种廣泛的兼容性允許与不同的图像来源和格式轻松集成。 Jacob Mellor 立即與工程團隊聊天 首席技術官 Jacob Mellor是Iron Software的首席技術官,也是開創C# PDF技術的前瞻性工程師。作為Iron Software核心代碼庫的原始開發者,他自公司成立以來就塑造了公司的產品架構,並與CEO Cameron Rimington將公司轉型為服務NASA、Tesla以及全球政府機構的50多人公司。Jacob擁有曼徹斯特大學土木工程一級榮譽學士學位(1998年–2001年)。他於1999年在倫敦開立首家軟體公司,並於2005年建立了他的第一個.NET組件,專注於解決Microsoft生態系統中的複雜問題。他的旗艦作品IronPDF和Iron Suite .NET程式庫全球已獲得超過3000萬次NuGet安裝,他的基礎代碼不斷在全球各地驅動開發者工具。擁有25年以上的商業經驗和41年的編碼專業知識,Jacob仍然專注於推動企業級C#、Java和Python PDF技術的創新,同時指導下一代技術領導者。 審核人 Jeffrey T. Fritz 首席程序经理 - .NET 社群团队 Jeff 也是 .NET 和 Visual Studio 团队的首席程序经理。他是 .NET Conf 虚拟会议系列的执行制作人,并主持“Fritz 和朋友”这一每周两次的開發者的直播节目,在节目上讨论技術并与观众一起编写代碼。Jeff 撰写研讨会、主持演讲,并计划大型 Microsoft 開發者活動(包括 Microsoft Build、Microsoft Ignite、.NET Conf 和 Microsoft MVP Summit)的內容。 準備好開始了嗎? Nuget 下載 5,525,971 | 版本: 2026.3 剛剛發布 開始免費試用 免費 NuGet 下載 總下載量:5,525,971 查看許可證 還在捲動嗎? 想要快速證明? PM > Install-Package IronOcr 執行範例 觀看您的圖片變成可搜尋的文字。 免費 NuGet 下載 總下載量:5,525,971 查看許可證