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 noiseinput.Deskew(); //fixes rotation and perspective// there are dozens more filters, but most users wont need themOcrResult 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);
ImportsIronOcrImportsSystemPrivate ocr = New IronTesseract()Private input = New OcrInput()Private pageindices = New Integer() { 1, 2 }input.LoadImageFrames("img\example.tiff", pageindices)input.DeNoise() 'fixes digital noiseinput.Deskew() 'fixes rotation and perspective' there are dozens more filters, but most users wont need themDim result AsOcrResult = 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++互操作的需要。Deskew())可以显著提高实际文档的准确性。
using IronOcr;using System;// Create an instance of the IronTesseract class for OCR processingvar ocr = new IronTesseract();// Create an OcrInput object to load and preprocess imagesusing var input = new OcrInput();// Specify which pages to extract from multi-page documentsvar pageIndices = new int[] { 1, 2 };// Load specific frames from a TIFF file// IronOCR automatically detects and handles various image formatsinput.LoadImageFrames(@"img\example.tiff", pageIndices);// Apply automatic image enhancement filters// These filters dramatically improve accuracy on imperfect scansinput.DeNoise(); // Removes digital artifacts and specklesinput.Deskew(); // Corrects rotation up to 15 degrees// Perform OCR with enhanced accuracy algorithmsOcrResult result = ocr.Read(input);// Access the extracted text with confidence metricsConsole.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
ImportsIronOcrImportsSystem' Create an instance of the IronTesseract class for OCR processingPrivate ocr = New IronTesseract()' Create an OcrInput object to load and preprocess imagesPrivate input = New OcrInput()' Specify which pages to extract from multi-page documentsPrivate pageIndices = New Integer() { 1, 2 }' Load specific frames from a TIFF file' IronOCR automatically detects and handles various image formatsinput.LoadImageFrames("img\example.tiff", pageIndices)' Apply automatic image enhancement filters' These filters dramatically improve accuracy on imperfect scansinput.DeNoise() ' Removes digital artifacts and specklesinput.Deskew() ' Corrects rotation up to 15 degrees' Perform OCR with enhanced accuracy algorithmsDim result AsOcrResult = ocr.Read(input)' Access the extracted text with confidence metricsConsole.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
Imports 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
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");
ImportsIronOcrPrivate ocr = New IronTesseract()ocr.Language = OcrLanguage.ArabicDim 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")
using IronOcr;// For the Chinese Language Pack:// PM> Install IronOcr.Languages.ChineseSimplifiedvar ocr = new IronTesseract();ocr.Language = OcrLanguage.ChineseSimplified;ocr.AddSecondaryLanguage(OcrLanguage.English);// We can add any number of languagesusing 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");
ImportsIronOcr' For the Chinese Language Pack:' PM> Install IronOcr.Languages.ChineseSimplifiedPrivate ocr = New IronTesseract()ocr.Language = OcrLanguage.ChineseSimplifiedocr.AddSecondaryLanguage(OcrLanguage.English)' We can add any number of languagesDim 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")
这种简化的应用程序接口消除了传统 Tesseract 集成的复杂性。 每种方法都包含全面的 XML 文档,方便您直接在集成开发环境中探索功能。广泛的 API 文档为每个功能提供了详细的示例。
using IronOcr;// Configure IronTesseract for Arabic text recognitionvar ocr = new IronTesseract{ // Set primary language to Arabic // Automatically handles right-to-left textLanguage = OcrLanguage.Arabic};// Load Arabic documents for processingusing 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 optimizationsvar result = ocr.Read(input);// Save results with proper Unicode encoding// Preserves Arabic text formatting and directionresult.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
ImportsIronOcr' Configure IronTesseract for Arabic text recognitionPrivate ocr = New IronTesseractWith {.Language = OcrLanguage.Arabic}' Load Arabic documents for processingPrivate 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 optimizationsDim result = ocr.Read(input)' Save results with proper Unicode encoding' Preserves Arabic text formatting and directionresult.SaveAsTextFile("arabic.txt")' Advanced Arabic features:' - Mixed Arabic/English document support' - Automatic number conversion (Eastern/Western Arabic)' - Font-specific optimization for common Arabic typefaces
Imports 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 OCRvar ocr = new IronTesseract();// Set primary language for majority contentocr.Language = OcrLanguage.ChineseSimplified;// Add secondary language for mixed content// Perfect for documents with Chinese text and English metadataocr.AddSecondaryLanguage(OcrLanguage.English);// Process multi-language PDFs efficientlyusing var input = new OcrInput();input.LoadPdf("multi-language.pdf");// IronOCR automatically detects and switches between languages// Maintains high accuracy across language boundariesvar result = ocr.Read(input);// Export preserves all languages correctlyresult.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.)
ImportsIronOcr' Install language packs via NuGet:' PM> Install-Package IronOcr.Languages.ChineseSimplified' Configure multi-language OCRPrivate ocr = New IronTesseract()' Set primary language for majority contentocr.Language = OcrLanguage.ChineseSimplified' Add secondary language for mixed content' Perfect for documents with Chinese text and English metadataocr.AddSecondaryLanguage(OcrLanguage.English)' Process multi-language PDFs efficientlyDim input = New OcrInput()input.LoadPdf("multi-language.pdf")' IronOCR automatically detects and switches between languages' Maintains high accuracy across language boundariesDim result = ocr.Read(input)' Export preserves all languages correctlyresult.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.)
How does IronOCR handle OCR for different image formats?
IronOCR automatically manages image conversions for various formats such as JPEG, PNG, BMP, and supports .NET types, providing a consistent API for all image processing needs.
Why is IronOCR a preferred choice for professional OCR solutions in C#?
IronOCR is preferred for professional OCR due to its ease of use, robust feature set, cross-platform compatibility, and reliable support, making it ideal for production environments.
Jacob Mellor 是 Iron Software 的首席技术官,也是一位开创 C# PDF 技术的有远见的工程师。作为 Iron Software 核心代码库的原始开发者,他从公司成立之初就开始塑造公司的产品架构,与首席执行官 Cameron Rimington 一起将公司转变为一家拥有 50 多名员工的公司,为 NASA、特斯拉和全球政府机构提供服务。