Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Optical Character Recognition (OCR) is a technology that transforms various document formats, including scanned paper documents, PDFs, digital file, or images of printed text taken with a digital camera, into editable and searchable machine-encoded text data.
IronOCR is a great OCR engine library that offers powerful OCR functionalities to developers. In this article, we will explore how to perform OCR using IronOCR with code examples with OCR Software Demo.
IronOCR is a powerful .NET library designed to facilitate optical character recognition (OCR) within C# and VB.NET applications. Leveraging advanced algorithms and machine learning techniques, IronOCR can accurately extract text and content from scanned PDF files, images, and PDFs, making it easier to process, search, and analyze such files programmatically.
With its straightforward API and extensive features, developers can seamlessly integrate OCR capabilities into their applications to automate data extraction, document processing, data entry, and content management tasks. Whether you're working on business, with invoices, reports, automated data extraction, a searchable PDF, or any other text-rich documents, IronOCR offers a reliable solution to handle OCR requirements efficiently.
Before diving into the code examples, you need to install IronOCR via NuGet Package Manager. You can install IronOCR by running the following command in the Package Manager Console:
Install-Package IronOcr
Install-Package IronOcr
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'Install-Package IronOcr
To perform basic text recognition using IronOCR, you can use the following code snippet:
using IronOcr;
using System;
IronTesseract ocrTesseract = new IronTesseract();
using (OcrInput ocrInput = new OcrInput("ocr.png"))
{
OcrResult ocrResult = ocrTesseract.Read(ocrInput);
string RecognizedText = ocrResult.Text;
Console.WriteLine(RecognizedText);
}
using IronOcr;
using System;
IronTesseract ocrTesseract = new IronTesseract();
using (OcrInput ocrInput = new OcrInput("ocr.png"))
{
OcrResult ocrResult = ocrTesseract.Read(ocrInput);
string RecognizedText = ocrResult.Text;
Console.WriteLine(RecognizedText);
}
Imports IronOcr
Imports System
Private ocrTesseract As New IronTesseract()
Using ocrInput As New OcrInput("ocr.png")
Dim ocrResult As OcrResult = ocrTesseract.Read(ocrInput)
Dim RecognizedText As String = ocrResult.Text
Console.WriteLine(RecognizedText)
End Using
This code uses IronOCR to perform optical character recognition (OCR) on an image file named "ocr.png". It initializes an IronTesseract object and reads the text layer of the image file into an OcrInput object.
The OCR result is then retrieved as RecognizedText and printed to the console.
- LOGO SHOP - LOREM IPSUM - DOLOR SITAMET CONSECTETUR - ADIPISCING ELIT - 1 LOREM IPSUM $3.20 - 2 ORNARE MALESUADA $9.50 - 3 PORTA FERMENTUM $5.90 - 4 SODALES ARCU $6.00 - 5 ELEIFEND $9.00 - 6 SEMNISIMASSA $0.50 - 7 DUIS FAMES DIS $7.60 - 8 FACILISIRISUS $810 - TOTAL AMOUNT $49.80 - CASH $50.00
- LOGO SHOP - LOREM IPSUM - DOLOR SITAMET CONSECTETUR - ADIPISCING ELIT - 1 LOREM IPSUM $3.20 - 2 ORNARE MALESUADA $9.50 - 3 PORTA FERMENTUM $5.90 - 4 SODALES ARCU $6.00 - 5 ELEIFEND $9.00 - 6 SEMNISIMASSA $0.50 - 7 DUIS FAMES DIS $7.60 - 8 FACILISIRISUS $810 - TOTAL AMOUNT $49.80 - CASH $50.00
'INSTANT VB TODO TASK: The following line uses invalid syntax: '- LOGO SHOP - LOREM IPSUM - DOLOR SITAMET CONSECTETUR - ADIPISCING ELIT - 1 LOREM IPSUM $3.20 - 2 ORNARE MALESUADA $9.50 - 3 PORTA FERMENTUM $5.90 - 4 SODALES ARCU $6.00 - 5 ELEIFEND $9.00 - 6 SEMNISIMASSA $0.50 - 7 DUIS FAMES DIS $7.60 - 8 FACILISIRISUS $810 - TOTAL AMOUNT $49.80 - CASH $50.00
VB C#
IronOCR provides various options that enable you to customize the OCR process according to your image files and requirements. For example, you can specify the OCR language, adjust the image preprocessing settings, or enable text cleaning. Here's an example that demonstrates some of these advanced options:
using IronOcr;
class Program
{
static void Main()
{
var ocr = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
// Set OCR language to English
ocr.Language = OcrLanguage.English;
// Enable text cleaning
ocrInput.DeNoise();
ocrInput.EnhanceResolution(225);
var result = ocr.Read(ocrInput);
if (result != null && result.Text != null)
{
Console.WriteLine($"Recognized Text: {result.Text}");
}
}
}
using IronOcr;
class Program
{
static void Main()
{
var ocr = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
// Set OCR language to English
ocr.Language = OcrLanguage.English;
// Enable text cleaning
ocrInput.DeNoise();
ocrInput.EnhanceResolution(225);
var result = ocr.Read(ocrInput);
if (result != null && result.Text != null)
{
Console.WriteLine($"Recognized Text: {result.Text}");
}
}
}
Imports IronOcr
Friend Class Program
Shared Sub Main()
Dim ocr = New IronTesseract()
Dim ocrInput As New OcrInput()
ocrInput.LoadImage("images\image.png")
' Set OCR language to English
ocr.Language = OcrLanguage.English
' Enable text cleaning
ocrInput.DeNoise()
ocrInput.EnhanceResolution(225)
Dim result = ocr.Read(ocrInput)
If result IsNot Nothing AndAlso result.Text IsNot Nothing Then
Console.WriteLine($"Recognized Text: {result.Text}")
End If
End Sub
End Class
The code uses IronOCR to perform OCR on an image file "image.png" located in the "images" folder. It sets the OCR language to English, cleans the image noise, and enhances its resolution. The recognized text from the image is extracted and then printed to the console.
IronOCR also supports barcode reading, allowing you to make software to extract barcode information from images. Here's a code example that demonstrates how to read a barcode using IronOCR:
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\imageWithBarcode.png");
var ocrResult = ocrTesseract.Read(ocrInput);
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine(barcode.Value);
}
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\imageWithBarcode.png");
var ocrResult = ocrTesseract.Read(ocrInput);
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine(barcode.Value);
}
Imports IronOcr
Imports System
Private ocrTesseract = New IronTesseract()
ocrTesseract.Configuration.ReadBarCodes = True
Dim ocrInput As New OcrInput()
ocrInput.LoadImage("images\imageWithBarcode.png")
Dim ocrResult = ocrTesseract.Read(ocrInput)
For Each barcode In ocrResult.Barcodes
Console.WriteLine(barcode.Value)
Next barcode
The code uses IronOCR to detect and read barcodes from an image file "imageWithBarcode.png" in the "images" folder. It configures IronOCR to enable barcode reading by setting ReadBarCodes to true. The detected barcode values are then printed to the console.
IronOCR can also extract text from PDFs and scanned documents. Here's a code example that demonstrates how to extract text from a PDF file using IronOCR:
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// OCR entire document
ocrInput.LoadPdf("Email_Report.pdf");
int[] pages = { 1, 2, 3, 4, 5 };
// Alternatively OCR selected page numbers
ocrInput.LoadPdfPages("example.pdf", pages, Password: "password");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// OCR entire document
ocrInput.LoadPdf("Email_Report.pdf");
int[] pages = { 1, 2, 3, 4, 5 };
// Alternatively OCR selected page numbers
ocrInput.LoadPdfPages("example.pdf", pages, Password: "password");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports System
Private ocrTesseract = New IronTesseract()
Private ocrInput = New OcrInput()
' OCR entire document
ocrInput.LoadPdf("Email_Report.pdf")
Dim pages() As Integer = { 1, 2, 3, 4, 5 }
' Alternatively OCR selected page numbers
ocrInput.LoadPdfPages("example.pdf", pages, Password:= "password")
Dim ocrResult = ocrTesseract.Read(ocrInput)
Console.WriteLine(ocrResult.Text)
The code uses IronOCR to perform OCR processing on a PDF document named "Email_Report.pdf". It can OCR the entire document using LoadPdf, or specific pages from "example.pdf" using LoadPdfPages with a password. The recognized text from the OCR operation is printed to the console.
IronOCR is a powerful .NET library that offers advanced OCR software capabilities, making it easy for developers to perform OCR tasks in their applications. In this article, we explored how to perform basic and advanced OCR Software Demo using IronOCR with code examples.
Whether you need to recognize handwritten text, various digital formats, to scan and read barcodes, or extract text from PDF documents, IronOCR has got you covered with its comprehensive set of features.
If you're working on a .NET project and need to integrate OCR functionality, IronOCR is definitely worth considering when looking at different OCR engines. Its ease of use, speed, flexibility, and extensive documentation make it a popular choice among developers for OCR automation tasks.
So why not give IronOCR a try and see how it can simplify your own OCR project development process? It may be the best OCR engine for your projects.
IronOCR offers a free trial license then start from $749 USD which allows you to continue to get the most out of IronOCR in your projects.
To know more about IronOCR visit here.
9 .NET API products for your office documents