How to Extract Read Results
The read or OCR result encompasses a wealth of information pertaining to detected paragraphs, lines, words, and individual characters. For each of these elements, the result provides a comprehensive set of details.
For each element, it provides the text content, precise X and Y coordinates, dimensions (width and height), text direction (Left to Right or Top to Bottom), and location in a CropRectangle object.
Get started with IronOCR
Start using IronOCR in your project today with a free trial.
How to Extract Read Results
- Download a C# library for accessing read results
- Prepare the target image and PDF document
- Use the
Read
method to perform OCR on the imported document - Access the X, Y, width, height, and text direction of the result
- Check the detected paragraphs, lines, words, and character comparisons
Data in OcrResult
The result value doesn't only contain the extracted text but also provides information about pages, paragraphs, lines, words, characters, and barcodes discovered in the PDF and image document by IronOcr. You can access this information from the returned OcrResult object using the Read
method.
:path=/static-assets/ocr/content-code-examples/how-to/read-results-output-information.cs
using IronOcr;
using System;
// The IronTesseract class is used to perform OCR tasks
var ocrTesseract = new IronTesseract();
// Using statement ensures that OcrInput resources are disposed of when no longer needed
using (var imageInput = new OcrInput("sample.jpg"))
{
try
{
// Perform OCR on the image and store the result
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Retrieve the list of detected paragraphs from the OCR result
Paragraph[] paragraphs = ocrResult.Paragraphs;
// Ensure that paragraphs were detected
if (paragraphs.Length > 0)
{
// Get the first detected paragraph
Paragraph firstParagraph = paragraphs[0];
// Output information of the first paragraph to the console
Console.WriteLine($"Text: {firstParagraph.Text}");
Console.WriteLine($"X: {firstParagraph.X}");
Console.WriteLine($"Y: {firstParagraph.Y}");
Console.WriteLine($"Width: {firstParagraph.Width}");
Console.WriteLine($"Height: {firstParagraph.Height}");
Console.WriteLine($"Text direction: {firstParagraph.TextDirection}");
}
else
{
Console.WriteLine("No paragraphs detected.");
}
}
catch (Exception ex)
{
// Catch and display any errors that occur during OCR processing
Console.WriteLine($"An error occurred during OCR processing: {ex.Message}");
}
}
Imports IronOcr
Imports System
' The IronTesseract class is used to perform OCR tasks
Private ocrTesseract = New IronTesseract()
' Using statement ensures that OcrInput resources are disposed of when no longer needed
Using imageInput = New OcrInput("sample.jpg")
Try
' Perform OCR on the image and store the result
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Retrieve the list of detected paragraphs from the OCR result
Dim paragraphs() As Paragraph = ocrResult.Paragraphs
' Ensure that paragraphs were detected
If paragraphs.Length > 0 Then
' Get the first detected paragraph
Dim firstParagraph As Paragraph = paragraphs(0)
' Output information of the first paragraph to the console
Console.WriteLine($"Text: {firstParagraph.Text}")
Console.WriteLine($"X: {firstParagraph.X}")
Console.WriteLine($"Y: {firstParagraph.Y}")
Console.WriteLine($"Width: {firstParagraph.Width}")
Console.WriteLine($"Height: {firstParagraph.Height}")
Console.WriteLine($"Text direction: {firstParagraph.TextDirection}")
Else
Console.WriteLine("No paragraphs detected.")
End If
Catch ex As Exception
' Catch and display any errors that occur during OCR processing
Console.WriteLine($"An error occurred during OCR processing: {ex.Message}")
End Try
End Using

For each part of the text, like paragraphs, lines, words, and individual characters, we provide the following information:
- Text: The actual text as a string.
- X: The position from the left edge of the page in pixels.
- Y: The position from the top edge of the page in pixels.
- Width: The width in pixels.
- Height: The height in pixels.
- Text Direction: The direction in which the text was read, like 'Left to Right' or 'Top to Bottom.'
- Location: A rectangle showing where this text is on the page in pixels.
Paragraph, Line, Word, and Character Comparison
Below is the comparison of the detected paragraphs, lines, words, and characters.
![]() Paragraph | ![]() Line |
![]() Word | ![]() Character |
Barcode and QR Code
That’s correct! IronOcr can read barcodes and QR codes. While the feature may not be as robust as IronBarcode, IronOcr does provide support for common barcode types. To enable barcode detection, set the Configuration.ReadBarCodes property to true.
Additionally, valuable information can be extracted from the detected barcode, including its format, value, coordinates (x, y), height, width, and location as IronSoftware.Drawing.Rectangle object. This Rectangle class in IronDrawing allows for precise positioning on the document.
:path=/static-assets/ocr/content-code-examples/how-to/read-results-barcodes.cs
using IronOcr;
using System;
// Instantiate IronTesseract
var ocrTesseract = new IronTesseract();
// Enable barcode detection
ocrTesseract.Configuration.ReadBarCodes = true;
// Add image for OCR processing
using (var ocrInput = new OcrInput())
{
// Load a PDF file into the OCR input
// Ensure the path is correct or that the file exists in the specified location
ocrInput.LoadPdf("sample.pdf");
// Perform OCR to extract text and barcode data
var ocrResult = ocrTesseract.Read(ocrInput);
// Output barcode information to console
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine("Format = " + barcode.Format);
Console.WriteLine("Value = " + barcode.Value);
Console.WriteLine("X Position = " + barcode.X);
Console.WriteLine("Y Position = " + barcode.Y);
}
// Output recognized text to console
Console.WriteLine(ocrResult.Text);
}
Imports IronOcr
Imports System
' Instantiate IronTesseract
Private ocrTesseract = New IronTesseract()
' Enable barcode detection
ocrTesseract.Configuration.ReadBarCodes = True
' Add image for OCR processing
Using ocrInput As New OcrInput()
' Load a PDF file into the OCR input
' Ensure the path is correct or that the file exists in the specified location
ocrInput.LoadPdf("sample.pdf")
' Perform OCR to extract text and barcode data
Dim ocrResult = ocrTesseract.Read(ocrInput)
' Output barcode information to console
For Each barcode In ocrResult.Barcodes
Console.WriteLine("Format = " & barcode.Format)
Console.WriteLine("Value = " & barcode.Value)
Console.WriteLine("X Position = " & barcode.X)
Console.WriteLine("Y Position = " & barcode.Y)
Next barcode
' Output recognized text to console
Console.WriteLine(ocrResult.Text)
End Using
Output

Frequently Asked Questions
What information does the OCR result provide?
The OCR result provides information about detected paragraphs, lines, words, and individual characters, including their text content, X and Y coordinates, dimensions, text direction, and location in a CropRectangle object.
How can I get started with IronOCR?
To get started with IronOCR, download the C# library from NuGet, prepare your target image or PDF document, use the Read method to perform OCR, and then access the result details such as X, Y, width, height, and text direction.
What types of text elements can IronOCR detect?
IronOCR can detect pages, paragraphs, lines, words, characters, and barcodes in PDF and image documents.
How does IronOCR handle barcode and QR code detection?
IronOCR can read barcodes and QR codes by setting Configuration.ReadBarCodes to true. It extracts information about the barcode's format, value, coordinates, height, width, and location.
What additional information can be extracted from a barcode using IronOCR?
With IronOCR, you can extract a barcode's format, value, and its position and dimensions (X, Y, width, height) as a Rectangle object.
Can IronOCR read text in different directions?
Yes, IronOCR can read text in different directions such as 'Left to Right' or 'Top to Bottom'.
What is the CropRectangle object used for in IronOCR?
The CropRectangle object in IronOCR is used to define the location of text elements on a page in terms of pixels, helping to identify their exact position and dimensions.
How do I use the Read method in IronOCR?
To use the Read method in IronOCR, instantiate an IronOCR object, load your document, and call the Read method to obtain OCR results, which can then be iterated through to access text data and properties.
What is the role of IronDrawing in barcode detection with IronOCR?
IronDrawing is used in barcode detection to determine the precise positioning of barcodes on the document using the Rectangle class, which provides coordinates and dimensions.
How can I enable barcode reading in IronOCR?
To enable barcode reading in IronOCR, set the Configuration.ReadBarCodes property to true before performing OCR on a document.