IRONSOFTWAREHOME

Word and Character OCR Data in C# (Coordinates, Confidence, Bounding Boxes)

Darrius Serrant
Darrius Serrant
Updated: August 2, 2026

After running OCR on a document, the extracted text alone is often not enough. To locate specific values on a page, exclude low-quality detections, or reconstruct the natural reading order on multi-column layouts, you need per-word coordinates, page numbers, region indices, and confidence scores.

The Words and Characters collections on OcrResult expose this data. Both ReadDocumentAdvanced() for layout-aware documents and ReadPhoto() for camera input return the same granularity available through the standard OcrResult.Words collection.

This guide walks through five common patterns: iterating word data, reconstructing reading order, filtering by confidence, working at the character level, and cropping the source image from a bounding box.

Start a free 30-day trial to test these collections in your pipeline.

NuGetInstall with NuGet

PM > Install-Package IronOcr

Install IronOCR by running the command above in the NuGet Package Manager Console, or search for the package in the NuGet Package Manager.
Quickstart: Read Word and Character Data from an OCR Result

Call ReadDocumentAdvanced (or ReadPhoto) and iterate result.Words to get every recognized word with its coordinates, page number, and confidence score in a few lines.

  1. 1Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. 2Copy and run this code snippet.

    using var input = new OcrInput();
    input.LoadImage("scan.png");
    var result = new IronTesseract().ReadDocumentAdvanced(input);
    foreach (var word in result.Words)
        Console.WriteLine($"{word.Text} @ ({word.X},{word.Y}) conf:{word.Confidence:P0}");
    C#
  3. 3Deploy to test on your live environment

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

How Do You Iterate Words with Coordinates and Confidence?

The Words collection returns every detected word across every page. Each entry (a Word or Character, both inheriting from OcrResultTextElement) exposes the text, pixel coordinates, dimensions, the page it belongs to, and a confidence score.

using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("receipt.png");

var result = ocr.ReadDocumentAdvanced(input);

foreach (var word in result.Words)
{
    Console.WriteLine(
        $"Page {word.PageNumber} | " +
        $"'{word.Text}' | " +
        $"Position: ({word.X}, {word.Y}) | " +
        $"Size: {word.Width}x{word.Height} | " +
        $"Confidence: {word.Confidence:P1}"
    );
}

// ToString() override for diagnostic logging
Console.WriteLine(result.Words.First().ToString());
C#
Tips: PageNumber is 1-based: page one is 1, not 0. This differs from most .NET collections, which use zero-based indexing.

To pass coordinates to drawing or cropping APIs, use the BoundingBox property. It bundles position and size into a single IronSoftware.Drawing.Rectangle.

How Do You Reconstruct Reading Order?

On multi-column layouts, the Words collection iteration order does not match the visual reading order on the page. Words are grouped by detected region, so columns and table cells can be returned out of sequence.

To rebuild a natural top-to-bottom, left-to-right order, sort the collection by Y coordinate first, then by X within each line. A small Y tolerance groups words sitting on the same baseline.

using IronOcr;
using System.Linq;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("multi-column-doc.png");

var result = ocr.ReadDocumentAdvanced(input);

int targetPage = 1;
int lineThreshold = 10; // pixel tolerance for grouping same-line words

// Sort by line (Y), then left-to-right (X)
var pageWords = result.Words
    .Where(w => w.PageNumber == targetPage)
    .OrderBy(w => w.Y / lineThreshold)
    .ThenBy(w => w.X)
    .ToList();

foreach (var word in pageWords)
{
    Console.Write($"{word.Text} ");
}
Console.WriteLine();

Tune lineThreshold to match your document: 10-15 pixels works for standard 12pt text at 300 DPI. Larger headings or handwritten input call for a wider tolerance. This pattern is especially useful on multi-column pages and inside table cells, where the engine detects each column or cell as its own region.

How Do You Filter Low-Confidence Words?

To exclude low-quality detections before they reach your database, search index, or downstream extraction, filter the collection by Confidence. The score ranges from 0.0 to 1.0, with higher values indicating greater confidence in the detected text.

using IronOcr;
using System.Linq;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("noisy-scan.png");

var result = ocr.ReadDocumentAdvanced(input);

double threshold = 0.75;

var highConfidenceWords = result.Words
    .Where(w => w.Confidence >= threshold)
    .ToList();

var lowConfidenceWords = result.Words
    .Where(w => w.Confidence < threshold)
    .ToList();

Console.WriteLine($"Accepted: {highConfidenceWords.Count} words");
Console.WriteLine($"Rejected: {lowConfidenceWords.Count} words");

// Log rejected words for manual review
foreach (var word in lowConfidenceWords)
{
    Console.WriteLine(
        $"  LOW CONF: '{word.Text}' at ({word.X},{word.Y}) — {word.Confidence:P1}"
    );
}
C#

For scans with mixed quality (clear print in some areas, degraded sections elsewhere), this prevents low-confidence output from reaching downstream systems. To raise confidence scores at the source, the image preprocessing filters (Deskew, DeNoise, Binarize) improve quality before the threshold is applied.

How Do You Iterate at the Character Level?

For OCR verification overlays, character-level diffing against ground truth, or precise spatial analysis on form fields, use the Characters collection. It mirrors Words but resolves down to individual characters.

using IronOcr;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("form-field.png");

var result = ocr.ReadDocumentAdvanced(input);

foreach (var ch in result.Characters)
{
    Console.WriteLine(
        $"'{ch.Text}' | " +
        $"Box: ({ch.X}, {ch.Y}, {ch.Width}, {ch.Height}) | " +
        $"Page {ch.PageNumber}"
    );
}

// ToString() override provides diagnostic-friendly output
Console.WriteLine(result.Characters.First().ToString());
Please note: Both Words and Characters are computed lazily and cached. The first access triggers the computation; subsequent accesses return the cached result, so iterating a second time costs nothing.

How Do You Crop the Original Image Using a BoundingBox?

To extract the visual region of a word for verification, annotation, or building labeled training data, pass the BoundingBox property to AnyBitmap.CropRegion(). The bounding box maps directly to the word's position in the source image.

using IronOcr;
using IronSoftware.Drawing;

var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("invoice.png");

var result = ocr.ReadDocumentAdvanced(input);

// Load the original image for cropping
var originalImage = AnyBitmap.FromFile("invoice.png");

// Find a specific word and crop its region
var targetWord = result.Words.FirstOrDefault(w => w.Text == "Total");
if (targetWord != null)
{
    Rectangle cropRect = targetWord.BoundingBox;
    AnyBitmap croppedRegion = originalImage.Clone(cropRect);
    croppedRegion.SaveAs("total-region.png");

    Console.WriteLine(
        $"Cropped '{targetWord.Text}' from " +
        $"({cropRect.X}, {cropRect.Y}, {cropRect.Width}, {cropRect.Height})"
    );
}

This pattern scales to bulk operations: iterate every word, crop each box, and export a labeled dataset for custom font training or downstream ML pipelines. Coordinates reflect the post-preprocessing image; if filters like EnhanceResolution changed the dimensions, the bounding box matches the processed image, not the original on disk.

Next Steps

The advanced pipeline provides the same spatial detail as IronTesseract.Read(), with additional layout intelligence on top. Related topics:

Start your free 30-day trial or view licensing options.

Frequently Asked Questions

What is the purpose of reading word and character data in OCR?

Reading word and character data in OCR allows you to access specific values on a page, filter low-quality detections, and reconstruct natural reading orders in documents with complex layouts. IronOCR's `Words` and `Characters` collections provide these capabilities.

How can I access the coordinates and confidence scores for recognized words?

Using IronOCR's `Words` collection, you can retrieve each word's text, pixel coordinates, dimensions, the page number it belongs to, and its confidence score. This data is essential for accurate spatial analysis and validation.

What method should be used for layout-aware document processing?

For layout-aware document processing, use the `ReadDocumentAdvanced()` method. It supports detailed word and character data extraction, making it suitable for documents with complex layouts.

How do you reconstruct the reading order in multi-column documents?

To reconstruct the reading order in multi-column documents, sort the `Words` collection by the Y coordinate and then by X within each line. This technique ensures a natural reading order, reflecting a top-to-bottom, left-to-right sequence.

How can low-confidence detections be filtered out?

Low-confidence detections can be filtered out by applying a confidence threshold. Words with a confidence score below this threshold can be excluded, ensuring that only high-quality detections are processed further.

Why is character-level data useful in OCR?

Character-level data is useful for tasks requiring high precision, such as OCR verification overlays, character-level diffing, or precise spatial analysis on form fields. IronOCR provides character-level granularity for such needs.

How can you crop an image using OCR data?

To crop an image using OCR data, you can use the `BoundingBox` property of a word or character in IronOCR. This can help in verification, annotation, or building labeled datasets, as it maps directly to the source image region.

What is the advantage of using `ReadDocumentAdvanced` over standard OCR methods?

`ReadDocumentAdvanced` provides additional layout intelligence, enabling detailed extraction of spatial data and handling of complex layouts. It offers the same spatial detail as `IronTesseract.Read()`, with enhanced features for advanced document processing.

What techniques can improve OCR confidence scores before filtering?

Preprocessing techniques such as de-skewing, de-noising, and binarization can improve image quality and thus increase OCR confidence scores. IronOCR provides filters to apply these improvements before text extraction.

How can OCR results be used for custom font training or machine learning?

OCR results, including cropped image regions and labeled datasets derived from bounding boxes, can be used to train custom fonts or feed machine learning pipelines. IronOCR facilitates these processes with its detailed spatial data extraction capabilities.

Darrius Serrant
Full Stack Software Engineer (WebOps)

Darrius Serrant holds a Bachelor’s degree in Computer Science from the University of Miami and works as a Full Stack WebOps Marketing Engineer at Iron Software. Drawn to coding from a young age, he saw computing as both mysterious and accessible, making it the perfect medium for creativity and problem-solving.

...
Read More

Ready to Get Started?

Nuget Downloads 6,236,385Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required