OCR in 1 line of code
IronOCR is unique in its ability to automatically detect and read text from imperfectly scanned images and PDF documents. The IronTesseract
class provides the simplest API.
Try other code samples to gain fine-grained control of your C# OCR operations.
IronOCR provides the most advanced build of Tesseract known anywhere, on any platform, with increased speed, accuracy, and a native DLL and API.
Supports Tesseract 3, Tesseract 4, and Tesseract 5 for .NET Framework, Standard, Core, Xamarin, and Mono.
How to OCR in VB.NET
- Install the VB.NET library to do OCR on image or PDF
- Instantiate
IronTesseract
to use intuitive APIs - Utilize
Read
method to perform OCR in VB.NET - Get OCR result by accessing
Text
property - Execute steps 2, 3, and 4 in a single line of code.
Imports IronOcr
' Instantiate the IronTesseract class to create a new OCR reader
Dim Ocr As New IronTesseract()
' Load an image or PDF document from which to extract the text
Dim Result = Ocr.Read("example_document.png")
' Output the extracted text from the OCR result onto the console
Console.WriteLine(Result.Text)
Imports IronOcr
' Instantiate the IronTesseract class to create a new OCR reader
Dim Ocr As New IronTesseract()
' Load an image or PDF document from which to extract the text
Dim Result = Ocr.Read("example_document.png")
' Output the extracted text from the OCR result onto the console
Console.WriteLine(Result.Text)
Detailed Explanation:
Instantiate IronTesseract: This step initializes an IronTesseract object which allows us to perform OCR operations. It provides the methods needed to read and extract text from images or documents.
Load and Read the Document: The
Read
method performs OCR on the provided file. In this example, it processes"example_document.png"
. This operation extracts text content from the image.- Output the Extracted Text: The result of the
Read
method contains a propertyText
, which holds the extracted text. This text is printed to the console usingConsole.WriteLine
.
By following these steps, you can easily perform OCR in VB.NET using the IronOCR library, allowing the automation of text extraction for various applications.