How to Extract Read Results in C# with IronOCR

IronOCR's Read method returns an OcrResult object containing extracted text plus detailed metadata including precise coordinates, dimensions, text direction, and hierarchical structure (paragraphs, lines, words, characters) for each detected element.

The OCR result contains comprehensive information about detected paragraphs, lines, words, and individual characters.

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.

Quickstart: Retrieve Word Text from First Detected Word

Use IronTesseract's Read method to OCR an image and extract the first word's text using the Words collection.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. Copy and run this code snippet.

    string wordText = new IronTesseract().Read("file.jpg").Words[0].Text;
  3. Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer

What Data Can I Extract from OCR Results?

The result value contains not only extracted text but also information about pages, paragraphs, lines, words, characters, and barcodes discovered in PDF and image documents by IronOCR. You can access this information from the returned OcrResult object using the Read method.

IronOCR's comprehensive results system builds on the powerful Tesseract 5 engine, providing developers with structured data extraction capabilities beyond simple text recognition. Whether processing scanned documents, photos, or screenshots, the OcrResult class gives you granular control over extracted data.

:path=/static-assets/ocr/content-code-examples/how-to/read-results-output-information.cs
using IronOcr;
using System;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.jpg");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Retrieve list of detected paragraphs
Paragraph[] paragraphs = ocrResult.Paragraphs;

// Output information to console
Console.WriteLine($"Text: {paragraphs[0].Text}");
Console.WriteLine($"X: {paragraphs[0].X}");
Console.WriteLine($"Y: {paragraphs[0].Y}");
Console.WriteLine($"Width: {paragraphs[0].Width}");
Console.WriteLine($"Height: {paragraphs[0].Height}");
Console.WriteLine($"Text direction: {paragraphs[0].TextDirection}");
Imports IronOcr
Imports System
Imports IronOcr.OcrResult

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Add image
Private imageInput = New OcrImageInput("sample.jpg")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)

' Retrieve list of detected paragraphs
Private paragraphs() As Paragraph = ocrResult.Paragraphs

' Output information to console
Console.WriteLine($"Text: {paragraphs(0).Text}")
Console.WriteLine($"X: {paragraphs(0).X}")
Console.WriteLine($"Y: {paragraphs(0).Y}")
Console.WriteLine($"Width: {paragraphs(0).Width}")
Console.WriteLine($"Height: {paragraphs(0).Height}")
Console.WriteLine($"Text direction: {paragraphs(0).TextDirection}")
$vbLabelText   $csharpLabel
Visual Studio debugger showing OCR extraction results with coordinates and text from Japanese business document

How Do I Access Text Content from OCR Results?

The OcrResult object presents extracted text in a simple, intuitive way, allowing developers to use it directly or integrate it into other application components. The hierarchical structure mirrors natural document text organization, making it straightforward to work with content at different granularity levels.

For applications requiring multiple language support, IronOCR seamlessly handles multilingual documents, maintaining the same structured result format across all 125 supported languages.

The following code example prints text in a loop to verify results.

:path=/static-assets/ocr/content-code-examples/how-to/read-results-output-text.cs
using IronOcr;
using System;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sampleText.png");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Retrieve list of detected paragraphs
Paragraph[] paragraphs = ocrResult.Paragraphs;

// Loop through each paragraph in the array
Console.WriteLine("--- All Detected Paragraphs ---");
foreach (Paragraph paragraph in paragraphs)
{
    // Print the text of the current paragraph
    Console.WriteLine(paragraph.Text);
    
    // Add a blank line for better separation (optional)
    Console.WriteLine(); 
}

IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Terminal displaying OCR paragraph detection results with extracted text about Masayoshi Son and Yasumitsu Shigeta

The console output shows IronOCR extracting paragraph text line by line with precision. The engine automatically detects paragraph boundaries, making it ideal for processing complex documents with multiple text blocks.

How Can I Get the Location Coordinates of Detected Text?

In addition to extracted text, the OcrResult provides detailed location data. This spatial information is crucial for applications that need to maintain layout fidelity or perform targeted text extraction from specific document regions. The coordinate system uses standard pixel measurements from the page's top-left corner.

For enhanced precision in coordinate-based operations, consider using OCR region targeting to focus on specific areas, or leverage Computer Vision capabilities to automatically identify text regions.

The following code demonstrates iterating over each paragraph and printing its coordinates (X and Y) to the console.

:path=/static-assets/ocr/content-code-examples/how-to/read-results-output-text.cs
using IronOcr;
using System;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sampleText.png");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Retrieve list of detected paragraphs
Paragraph[] paragraphs = ocrResult.Paragraphs;

// Loop through each paragraph in the array
Console.WriteLine("--- All Detected Paragraphs ---");
foreach (Paragraph paragraph in paragraphs)
{
    // Print the text of the current paragraph
    Console.WriteLine(paragraph.Text);
    
    // Add a blank line for better separation (optional)
    Console.WriteLine(); 
}

IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Terminal output showing OCR detected paragraph coordinates with X,Y values: (29,30), (28,74), and (27,362)

The output shows three sets of coordinates corresponding to three paragraphs. These coordinates can be used for drawing bounding boxes, extracting specific regions, or maintaining spatial relationships between text elements.

What Other Attributes Are Available in OCR Results?

Besides text and text coordinates, IronOCR provides additional information. For each text element (paragraphs, lines, words, and individual characters), the following information is available:

  • 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 text was read (Left to Right or Top to Bottom).
  • Location: A rectangle showing where this text is on the page in pixels.

These attributes are particularly useful when implementing:

  • Text highlighting and annotation systems
  • Automated form field detection
  • Layout preservation in document conversion
  • Spatial text analysis for data extraction

For debugging and visualization, use the highlight texts feature to visually verify detected region accuracy.

How Do Paragraphs, Lines, Words, and Characters Compare?

IronOCR's hierarchical text structure allows developers to work at the appropriate detail level for their specific use case. Understanding differences between these elements helps choose the right granularity for your application.

Below is the comparison of detected paragraphs, lines, words, and characters.

Highlighted biographical profiles of Japanese tech entrepreneurs Masayoshi Son and Yasumitsu Shigeta
Document with red highlighting showing profiles of Japanese tech executives Masayoshi Son and Yasumitsu Shigeta
Text highlighting feature showing red boxes overlaying selected words in a paragraph about tech investments
Character-level text detection showing individual character boundaries in OCR results

Each granularity level serves different purposes:

  • Paragraphs: Best for document structure analysis and bulk text extraction
  • Lines: Useful for maintaining reading order and processing tabular data
  • Words: Ideal for search functionality and text analysis
  • Characters: Perfect for spell-checking and precise text editing applications

Can IronOCR Read Barcodes and QR Codes?

Yes, IronOCR can read barcodes and QR codes. While the feature may not be as robust as IronBarcode, IronOCR provides support for common barcode types. To enable barcode detection, set the Configuration.ReadBarCodes property to true. This integrated functionality makes IronOCR an excellent choice for processing documents containing both text and barcodes, such as invoices, shipping labels, or product catalogs.

Additionally, valuable information can be extracted from detected barcodes, including 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.

For more advanced barcode reading scenarios, check out the comprehensive barcode reading examples in our documentation.

:path=/static-assets/ocr/content-code-examples/how-to/read-results-barcodes.cs
using IronOcr;
using System;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Enable barcodes detection
ocrTesseract.Configuration.ReadBarCodes = true;

// Add image
using OcrInput ocrInput = new OcrInput();
ocrInput.LoadPdf("sample.pdf");

// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(ocrInput);

// Output information to console
foreach(var barcode in ocrResult.Barcodes)
{
    Console.WriteLine("Format = " + barcode.Format);
    Console.WriteLine("Value = " + barcode.Value);
    Console.WriteLine("X = " + barcode.X);
    Console.WriteLine("Y = " + barcode.Y);
}
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports System
Imports IronOcr.OcrResult

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Enable barcodes detection
ocrTesseract.Configuration.ReadBarCodes = True

' Add image
Using ocrInput As New OcrInput()
	ocrInput.LoadPdf("sample.pdf")
	
	' Perform OCR
	Dim ocrResult As OcrResult = ocrTesseract.Read(ocrInput)
	
	' Output information to console
	For Each barcode In ocrResult.Barcodes
		Console.WriteLine("Format = " & barcode.Format)
		Console.WriteLine("Value = " & barcode.Value)
		Console.WriteLine("X = " & barcode.X)
		Console.WriteLine("Y = " & barcode.Y)
	Next barcode
	Console.WriteLine(ocrResult.Text)
End Using
$vbLabelText   $csharpLabel

What Does the Barcode Detection Output Look Like?

The barcode detection feature in IronOCR seamlessly integrates with text extraction, providing unified results including both textual content and barcode data. This dual capability is valuable for automated document processing workflows where both information types need extraction and correlation.

Debug console showing QR code and EAN8 barcode detection results with formats, values, and coordinates

The output demonstrates IronOCR's ability to detect multiple barcode types simultaneously, providing format identification (such as QRCode or EAN8), decoded values, and precise coordinate information for each detected code. This comprehensive data allows developers to build sophisticated document processing applications that handle mixed content types efficiently.

Frequently Asked Questions

What information does the OcrResult object contain?

The OcrResult object from IronOCR contains extracted text plus detailed metadata including precise X/Y coordinates, dimensions (width and height), text direction (Left to Right or Top to Bottom), and hierarchical structure organized as paragraphs, lines, words, and individual characters for each detected element.

How can I quickly extract the first word from an OCR result?

You can extract the first word's text using IronOCR's Read method and accessing the Words collection: `string wordText = new IronTesseract().Read("file.jpg").Words[0].Text;`. This provides instant access to individual word elements from the OCR results.

What types of coordinate data are available in OCR results?

IronOCR provides precise X and Y coordinates for each detected element (paragraphs, lines, words, and characters), along with width and height dimensions. This coordinate data is accessible through the CropRectangle object, enabling precise location tracking of text elements.

Can I extract metadata beyond just text content?

Yes, IronOCR extracts comprehensive metadata including pages, paragraphs, lines, words, characters, and even barcodes discovered in PDF and image documents. The OcrResult object provides access to text direction, hierarchical structure, and spatial information for each element.

What document types can be processed for OCR results?

IronOCR can process various document types including scanned documents, photos, screenshots, PDFs, and image files. The Read method works consistently across these formats, returning the same structured OcrResult object with full metadata.

How is the extracted text organized in the results?

IronOCR organizes extracted text in a hierarchical structure that mirrors natural document organization. The OcrResult object presents content at different granularity levels - from entire pages down to individual characters - making it easy to work with text at the appropriate level for your application.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
Ready to Get Started?
Nuget Downloads 5,246,844 | Version: 2025.12 just released