Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
OCR stands for Optical Character Recognition. This is the technology that uses a machine to convert images of text into digital text that can be searched and edited.
This technology has been around for some time, but it is becoming more popular with the advancement of machine learning. Just recently, in the past couple of years, computer scientists have developed an algorithm that can actually read cursive handwriting, which many people still use today, including doctors and lawyers. The uses for this tool include scanning a whole book, extracting the text from a single letter, converting a whole PDF file into an editable format, document recognition, TIFF platform independence etc. Optical Character Recognition engine can be used in many different industries such as media and publishing companies, law firms, libraries, public records agencies, and more. Many companies use OCR software to digitize paper checks and statements, automatically correct spellings, or for recognized text console, thereby saving time and effort when scanning documents by hand.
Sometimes text from images will not be in English. In that case, what people need to do is to use an OCR tool to perform OCR that will run translation on the PNG image before it can extract and convert the text into English characters.
In this article, we are going to compare two of the most common libraries and applications for OCR raster formats and PDF document images. These are:
Aspose.OCR for .NET is a powerful and robust package for Optical Character Recognition. This is an excellent addition to any application and can automate the process. The standalone OCR API is extensible, user-friendly, and compact. It comes with a simple set of classes that provide all the functionality you need to get started recognizing text without any additional hassle and maintain correct text order. Aspose.OCR can read over 100 different formats and provides a myriad of useful functions, ranging from the ability to read fonts, apply style effects (bold/italic), and even remove noise from your image. The API can use the GPU to perform Optical Character Recognition and save power on your CPU.
For integration of toggle navigation, Aspose is a good option out there. Recognized text console and document text recognition or image to text or image OCR API are examples of functionalities that may be useful.
In addition to the automatic spell-check, image detection software is also designed to support a variety of output formats (such as PNG) and ignore non-textual blocks without requiring an additional OCR API. Standalone API features can be accessed in development environment to capture text from images.
IronOCR for .NET reads text content from photos and PDFs in .NET apps and websites. The software helps to scan photos for text and barcodes. It outputs content as plain text or structured data. IronOCR supports numerous worldwide languages. The OCR library can be used in MVC, Web, Console, and desktop .NET applications. For commercial deployments, licensing is provided with direct assistance from the development team.
Open Visual Studio and go to the File menu. Select New project, then select Console Application.
Enter the project name and select the file path in the appropriate text box. Then, click the Create button and choose a .NET Framework:
The project will now generate the structure for the selected application.
We can install the Aspose.OCR API in our application using NuGet. Just go to the Tools menu in Visual Studio and select the NuGet Package Manager. From the side menu, select Manage NuGet Package for a solution. It will open a NuGet Package Manager window. Go to the Browse tab and search for Aspose.OCR. Then select the Aspose API from the search results and click the "Install" button. The Aspose API will be installed and ready to use in the project.
Similarly, you can install Aspose.OCR using the Console. Open the NuGet console, which is usually located at the bottom of a Visual Studio project, write the following command, and hit enter.
“Install-Package Aspose.OCR -Version x.x.0”
The IronOCR library can be downloaded and installed in four ways.
These are:
The below screenshot shows how to open the NuGet Package Manager.
In the Package Manager window, click on Browse and search for the keyword "IronOCR", as in the below screenshot:
From the above image, we can see the list of the related searches. We need to select the required option to install the package to the solution.
Install-Package IronOcr
The third way is to download the NuGet package directly from the website.
Click the link here to download the latest package directly from the website. Once downloaded, follow the steps below to add the package to the project.
Both IronOCR and Aspose.OCR have an OCR technology that will convert images into text.
The following code snippet demonstrates the use of the RecognizeImage
method to perform an OCR operation on the image of a page.
// For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_OCR();
// Initialize an instance of AsposeOcr
AsposeOcr api = new AsposeOcr();
// Recognize image
string result = api.RecognizeImage(dataDir + "Sampleocr.bmp");
// Display the recognized text
Console.WriteLine(result);
// For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_OCR();
// Initialize an instance of AsposeOcr
AsposeOcr api = new AsposeOcr();
// Recognize image
string result = api.RecognizeImage(dataDir + "Sampleocr.bmp");
// Display the recognized text
Console.WriteLine(result);
' For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_OCR()
' Initialize an instance of AsposeOcr
Dim api As New AsposeOcr()
' Recognize image
Dim result As String = api.RecognizeImage(dataDir & "Sampleocr.bmp")
' Display the recognized text
Console.WriteLine(result)
The following code snippet demonstrates the use of the RecognizeLine
method to perform an OCR operation on an image containing a single line.
// For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_OCR();
// Initialize an instance of AsposeOcr
AsposeOcr api = new AsposeOcr();
// Recognize image
string result = api.RecognizeLine(dataDir + "sample_line.png");
// Display the recognized text
Console.WriteLine(result);
// For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_OCR();
// Initialize an instance of AsposeOcr
AsposeOcr api = new AsposeOcr();
// Recognize image
string result = api.RecognizeLine(dataDir + "sample_line.png");
// Display the recognized text
Console.WriteLine(result);
' For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_OCR()
' Initialize an instance of AsposeOcr
Dim api As New AsposeOcr()
' Recognize image
Dim result As String = api.RecognizeLine(dataDir & "sample_line.png")
' Display the recognized text
Console.WriteLine(result)
var Ocr = new IronTesseract(); // nothing to configure
Ocr.Language = OcrLanguage.EnglishBest;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
using (var Input = new OcrInput())
{
Input.AddImage(@"3.png");
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
Console.ReadKey();
}
var Ocr = new IronTesseract(); // nothing to configure
Ocr.Language = OcrLanguage.EnglishBest;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
using (var Input = new OcrInput())
{
Input.AddImage(@"3.png");
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
Console.ReadKey();
}
Dim Ocr = New IronTesseract() ' nothing to configure
Ocr.Language = OcrLanguage.EnglishBest
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
Using Input = New OcrInput()
Input.AddImage("3.png")
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
Console.ReadKey()
End Using
The Tesseract 5 API, which allows us to convert image files into text, is demonstrated above. We're making an object for IronTesseract
in the above line of code. We're also making an OcrInput
object that will allow us to add one or more picture files. We may need to give the available picture path inside the code when utilizing the OcrInput
object method add. Any number of images can be added. The function "Read" in the IronTesseract
object that we constructed before may be utilized to get the images by parsing the image file and extracting the result into the OCR result. It is capable of extracting text from photos and converting it to a string.
We can also use Tesseract to add multi-frame images. AddMultiFrameTiff
is a different method for this operation. The Tesseract library reads each frame in the image, and each frame is treated as a distinct page. The process will read the first frame of the image and then proceed on to the next frame, and so on until all of the image's frames have been scanned. Only the TIFF image format is supported by this method.
The above image is the output of the IronOCR result which has accurately converted the data into editable text.
IronOCR and Aspose.OCR convert PDF files into editable text. Aspose.OCR provides a list of options to the user such as save the page, edit the image, recognizing the page, etc. It also provides save options such as text, document, HTML format, etc. IronOCR also allows us to save a converted OCR file into HTML, text, PDF, etc.
Aspose.OCR provides the RecognizePdf
method that can recognize text in the images extracted from scanned PDF files. The RecognizePdf
method takes the PDF path as a parameter and the DocumentRecognitionSettings
object. The following code snippet demonstrates the use of the RecognizePdf method
to recognize images from a scanned multipage PDF file.
// The path to the PDF file
string dataDir = RunExamples.GetDataDir_OCR();
// Archive Path
string fullPath = dataDir + "OCR.pdf";
// Recognize images from PDF
DocumentRecognitionSettings set = new DocumentRecognitionSettings();
set.DetectAreas = false;
List<RecognitionResult> result = api.RecognizePdf(imgPath, set);
// Print result
int pageNumber = 0;
foreach (var page in result)
{
System.Console.WriteLine($"Page: {pageNumber++} text: {page.RecognitionText}");
}
// The path to the PDF file
string dataDir = RunExamples.GetDataDir_OCR();
// Archive Path
string fullPath = dataDir + "OCR.pdf";
// Recognize images from PDF
DocumentRecognitionSettings set = new DocumentRecognitionSettings();
set.DetectAreas = false;
List<RecognitionResult> result = api.RecognizePdf(imgPath, set);
// Print result
int pageNumber = 0;
foreach (var page in result)
{
System.Console.WriteLine($"Page: {pageNumber++} text: {page.RecognitionText}");
}
' The path to the PDF file
Dim dataDir As String = RunExamples.GetDataDir_OCR()
' Archive Path
Dim fullPath As String = dataDir & "OCR.pdf"
' Recognize images from PDF
Dim [set] As New DocumentRecognitionSettings()
[set].DetectAreas = False
Dim result As List(Of RecognitionResult) = api.RecognizePdf(imgPath, [set])
' Print result
Dim pageNumber As Integer = 0
For Each page In result
'INSTANT VB WARNING: An assignment within expression was extracted from the following statement:
'ORIGINAL LINE: System.Console.WriteLine(string.Format("Page: {0} text: {1}", pageNumber++, page.RecognitionText));
System.Console.WriteLine($"Page: {pageNumber} text: {page.RecognitionText}")
pageNumber += 1
Next page
We can also use OCRInput
to manage PDF files. Every page of a document will be read by the IronTesseract
class. The text will then be extracted from the pages. We may also open protected documents using a second function called AddPDF
, which allows us to add PDFs to our list of documents (password if it is protected). The following code demonstrates how to open a password-protected PDF document:
var Ocr = new IronTesseract(); // nothing to configure
using (var Input = new OcrInput())
{
Input.AddPdf("example.pdf", "password");
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
var Ocr = new IronTesseract(); // nothing to configure
using (var Input = new OcrInput())
{
Input.AddPdf("example.pdf", "password");
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Dim Ocr = New IronTesseract() ' nothing to configure
Using Input = New OcrInput()
Input.AddPdf("example.pdf", "password")
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using
We can read and extract content from a single page in a PDF document using AddPdfPage
. Only the page number from which we want to extract text needs to be specified. AddPdfPage
allows us to extract text from numerous pages that we specify. In IEnumerable<int>
, we can easily specify multiple pages. We must also include the file location as well as the extension of the file. This is demonstrated in the following code example:
IEnumerable<int> numbers = new List<int> {2,8,10 };
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
//single page
Input.AddPdfPage("example.pdf",10);
//Multiple page
Input.AddPdfPages("example.pdf", numbers);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
Result.SaveAsTextFile("ocrtext.txt");
}
IEnumerable<int> numbers = new List<int> {2,8,10 };
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
//single page
Input.AddPdfPage("example.pdf",10);
//Multiple page
Input.AddPdfPages("example.pdf", numbers);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
Result.SaveAsTextFile("ocrtext.txt");
}
Dim numbers As IEnumerable(Of Integer) = New List(Of Integer) From {2, 8, 10}
Dim Ocr = New IronTesseract()
Using Input = New OcrInput()
'single page
Input.AddPdfPage("example.pdf",10)
'Multiple page
Input.AddPdfPages("example.pdf", numbers)
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
Result.SaveAsTextFile("ocrtext.txt")
End Using
Using the SaveAsTextFile
function, we can store the result as a text file, which allows us to download the file to the output directory path. Also, we can save the file into an HTML file using SaveAsHocrFile.
Aspose.OCR has some additional options such as Draw Text Area, Draw Picture Area, Draw Table Area, Draw Recognize Area, etc. These all help the user to improve the performance of the OCR. Not only does the application perform OCR, but we are also able to perform operations such as combine PDFs, split PDFs, edit PDFs, etc.
IronOCR has unique features which allow us to read barcodes and QR codes from scanned documents. The below codes show how we can read a barcode from a given image or document.
var Ocr = new IronTesseract(); // nothing to configure
Ocr.Language = OcrLanguage.EnglishBest;
Ocr.Configuration.ReadBarCodes = true;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
using (var Input = new OcrInput())
{
Input.AddImage("barcode.gif");
var Result = Ocr.Read(Input);
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
}
}
var Ocr = new IronTesseract(); // nothing to configure
Ocr.Language = OcrLanguage.EnglishBest;
Ocr.Configuration.ReadBarCodes = true;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
using (var Input = new OcrInput())
{
Input.AddImage("barcode.gif");
var Result = Ocr.Read(Input);
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
}
}
Dim Ocr = New IronTesseract() ' nothing to configure
Ocr.Language = OcrLanguage.EnglishBest
Ocr.Configuration.ReadBarCodes = True
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
Using Input = New OcrInput()
Input.AddImage("barcode.gif")
Dim Result = Ocr.Read(Input)
For Each Barcode In Result.Barcodes
Console.WriteLine(Barcode.Value)
Next Barcode
End Using
The above is the code that helps to read a barcode from a given image or PDF document. It can read more than one barcode from the page/image. To read the barcode, IronOCR has a unique setting, Ocr.Configuration.ReadBarCodes
. The default value is set to false.
After reading the input, the data will be saved into the object called OCRResult
. This has a property called Barcodes, and it will have all the available barcode data in a list. By using the foreach
loop, we can get all the barcode details one by one. Also, it will scan the barcode and read the value of the barcode — two operations completed in one process.
It will also support threading options. We can perform multiple OCR processes at one time. IronOCR is also able to recognize a specific area from a specified region.
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
Input.Add("document.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
Input.Add("document.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Dim Ocr = New IronTesseract()
Using Input = New OcrInput()
Dim ContentArea = New System.Drawing.Rectangle() With {
.X = 215,
.Y = 1250,
.Height = 280,
.Width = 1335
}
Input.Add("document.png", ContentArea)
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using
The above is the sample code to perform OCR on a specific region. We only need to specify the rectangular region in the image or PDF. The Tesseract engine in IronOCR helps us to recognize the text.
A 30-day money-back guarantee: IronOCR has a 30-day money-back policy. So, if you change your mind after purchasing the software, you can claim your money within 30 days for a refund.
Easy integration: The integration of IronOCR with a project and environment is so easy that we can do it by just writing a single line of code and adding it from NuGet Package. Or, we can download it from the web and integrate it with our environment that way.
Perpetual Licensing: Each license is purchased once and does not require renewal.
Free Support and Product Updates: Every license comes with a year of free product updates and support from the team behind the product. It is possible to purchase extensions at any moment. Extensions can be viewed.
Immediate Licenses: Registered license keys are sent out as soon as payment is received.
All licenses are perpetual and apply to development, staging, and production.
This package allows a single software developer in an organization to utilize this Iron Software in a single place. It can be used in a single web application, intranet application, or desktop software program. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, without OEM redistribution and utilizing Iron Software as a SaaS without purchasing additional coverage.
Pricing: Starts from $499 per year.
This allows a predetermined number of software developers in an organization to utilize this Iron Software in single locations, up to a maximum of ten. IronOCR can be used in as many websites, intranet applications, or desktop software applications as you like. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS without purchasing additional coverage. This license can be integrated with a single project up to a maximum of 10.
Pricing: Starts from $999 per year.
This allows an unlimited number of software developers in an organization to utilize this Iron Software in an unlimited number of locations. It can be used in as many websites, intranet applications, or desktop software applications as you like. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS without purchasing additional coverage.
Pricing: Starts from $2999 per year.
Royalty-Free Redistribution — This allows you to distribute this Iron Software as part of a number of differently packaged commercial products (without having to pay royalties) based on the number of projects covered by the base license. It allows for the deployment of the Iron Software within SaaS software services, based on the number of projects covered by the base license.
Pricing: Starts from $1599 per year.
A developer small business license permits a developer to create unlimited end-user software using the product, and install it at only one physical location within their organization. When deploying end-user software, you'll need to purchase a license for each developer in your development team or for each physical location where it will be used. The developer small business license does not allow you to distribute your end-user software to third parties, public-facing websites, and applications, extranets, multi-site intranets, or Software as a Service (SaaS) project usage scenarios. You can only deploy the applications you develop using an OEM license to a single client. If you want to create libraries for use by other companies or distribute your creations as open-source software, then you will need a different type of license.
Pricing: Starts from $799 per year.
The developer OEM license means that one developer can use the product on any number of computers at any location where they are. So, if you're working in one office but need to get some work done at another for an hour — that is possible with this kind of license. An OEM developer license covers one producer of software products — i.e. someone who is not an authorized dealer of the product but is making software that uses its functions. In order to distribute end-user software to an end-user, you will need this license type. To allow for the distribution of end-user software to third parties, public-facing websites/applications, extranets, multi-site intranets, or SaaS project usage scenarios, a developer license must be purchased for each developer on the development team. This license does not support creating software such as an API or SDK for end-users.
Pricing: Starts from $2397 per year.
A Site Small Business License allows up to ten developers to create unlimited end-user software using the product, which can be used at any of your ten physical locations (e.g. separate office buildings, or if you're not a business with multiple offices, any physical location). If you have more than ten developers or you want to use Aspose on more than ten locations, then you can buy a multiple-site small business license. This license does not support the distribution of the software created with this license to other organizations.
Pricing: Starts from $3995 per year.
A Metered OEM License supports unlimited developers, unlimited locations, and unlimited end-user software. It allows users to distribute the end-user software to a third party. The metered OEM license is for publicly-facing websites/apps and can be used to support extranets or SaaS projects. It creates end-user software that is used in a development library that has an API or SDK.
Pricing: Starts from $1999 per year.
The IronOCR Lite license including one developer package with one year of support costs around $499, while Aspose.OCR with a one-developer package costs $799 with free technical support, and $1,198 with paid support. The IronOCR Professional license including 10-developer packages and one year of support costs $999, while the Aspose Site OEM including 10-developer packages costs $11,186 per year with free technical support, while paid technical releases and updates raise that figure to $23,171.
The IronOCR Lite and Professional packages have SaaS service or OEM and a 5-year support option. The Lite package, including a one-developer package with 5-year support and SaaS and OEM service, costs $2,897, while Aspose has SaaS or OEM service and customized support options. The IronOCR Professional license includes a 10-developer package with one year of paid support, and SaaS and OEM service, all for the price of $23,171, while Aspose offers a 10-developer package without support but with SaaS and OEM service for the price of $11,186.
IronOCR in the .NET framework context provides Tesseract that is straightforward and easy to use. It supports photos and PDF documents in a variety of ways. It also provides a number of settings for improving the Tesseract OCR library's performance. Various languages are supported in a single operation. To discover more about the Tesseract OCR, visit their website.
Aspose OCR is a software application that uses an artificial intelligence engine to recognize images and PDF documents. It also provides various settings to improve the performance of the OCR process. Further, it provides the option to select multiple languages and then perform OCR. Aspose has some limitations on the usage of page conversions. It also has a different price for different operating systems.
IronOCR packages provide better licensing and support compared to Aspose. Also, Aspose is more expensive. IronOCR starts from $499, while Aspose starts at $999 per year. Further, IronOCR provides more features compared to Aspose, and it supports multiple platforms at a single price.
So, what are you waiting for? The free trial is open to all. You can obtain the license here and begin straightaway.
9 .NET API products for your office documents