Class OcrResult.OcrResultTextElement
Inheritance
System.Object
OcrResult.OcrResultTextElement
Implements
IronSoftware.Abstractions.Pdf.IDocumentTextObject
IronSoftware.Abstractions.Pdf.IBoundedPdfDocumentObject
IronSoftware.Abstractions.Pdf.IPdfDocumentObject
IronSoftware.Abstractions.IDocumentObject
IronSoftware.Abstractions.IBounded
IronSoftware.ITransformable
IronSoftware.Abstractions.IColored
System.ICloneable
Assembly: IronOcr.dll
Syntax
public abstract class OcrResultTextElement : OcrResult.OcrResultElement
OcrResultTextElement is the shared shape behind every piece of recognized text an OCR read returns. Whenever you walk the words, lines, paragraphs, tables, or pages of an OcrResult, each item is built on this element, so the same handful of properties answer "what does it say, how sure is the engine, and where is it on the page" no matter which level you are inspecting.
A developer rarely constructs this element directly. It arrives as the base of the concrete result types: OcrResult.Word, OcrResult.Line, OcrResult.Paragraph, OcrResult.Table, and OcrResult.Page all derive from it, and you receive them by reading their arrays off the result. Because the element is abstract, you work with it through those derived types, but you read the same members on each one, which is what makes post-processing an OCR result uniform.
The members you reach for first are Text, the recognized string for that element (truncated when the product is unlicensed), and Confidence, the averaged per-character accuracy where 1 is 100 percent. BoundingBox gives the position as a RectangleF, Color reports the detected text color, and TextDirection returns an OcrResult.TextFlow so you can tell left-to-right text from right-to-left or vertical scripts. Contents is a synonym of Text, and Clone produces a copy when you need to detach an element from its result. Filter by Confidence to drop low-quality reads, and read BoundingBox to draw highlights or crop regions.
using IronOcr;
var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("scan.png");
OcrResult result = ocr.Read(input);
foreach (OcrResult.Word word in result.Pages[0].Words)
Console.WriteLine($"{word.Text} ({word.Confidence:P0})");
The OCR results objects example walks the result tree, and the reading results how-to shows how to pull text, confidence, and position from each element.
Constructors
OcrResultTextElement()
Declaration
protected OcrResultTextElement()
Properties
Bottom
Declaration
public double Bottom { get; set; }
Property Value
| Type |
Description |
| System.Double |
|
BoundingBox
Declaration
public RectangleF BoundingBox { get; set; }
Property Value
| Type |
Description |
| System.Drawing.RectangleF |
|
Color
Declaration
public Color Color { get; set; }
Property Value
| Type |
Description |
| System.Drawing.Color |
|
Confidence
OCR statistical accuracy confidence as an average of every character within this object.
1 = 100%, 0 = 0%
Declaration
public virtual double Confidence { get; }
Property Value
| Type |
Description |
| System.Double |
|
Contents
Declaration
public string Contents { get; set; }
Property Value
| Type |
Description |
| System.String |
|
Left
Declaration
public double Left { get; set; }
Property Value
| Type |
Description |
| System.Double |
|
Matrix
Declaration
public MatrixStruct Matrix { get; }
Property Value
| Type |
Description |
| IronSoftware.MatrixStruct |
|
ObjNum
Declaration
public uint ObjNum { get; set; }
Property Value
| Type |
Description |
| System.UInt32 |
|
PageIndex
Declaration
public uint PageIndex { get; set; }
Property Value
| Type |
Description |
| System.UInt32 |
|
PdfDocumentId
Declaration
public IDocumentId PdfDocumentId { get; set; }
Property Value
| Type |
Description |
| IronSoftware.Abstractions.Pdf.IDocumentId |
|
Right
Declaration
public double Right { get; set; }
Property Value
| Type |
Description |
| System.Double |
|
Scale
Declaration
public PointF Scale { get; set; }
Property Value
| Type |
Description |
| System.Drawing.PointF |
|
Text
The full text of this OcrResultElement as a string. This is truncated when the product is unlicensed.
Declaration
public string Text { get; set; }
Property Value
| Type |
Description |
| System.String |
|
TextDirection
The direction text was read in: such as 'Left to Right' or 'Top to Bottom'.
Declaration
public OcrResult.TextFlow TextDirection { get; }
Property Value
Top
Declaration
public double Top { get; set; }
Property Value
| Type |
Description |
| System.Double |
|
Translate
Declaration
public PointF Translate { get; set; }
Property Value
| Type |
Description |
| System.Drawing.PointF |
|
Methods
Clone()
Declaration
Returns
| Type |
Description |
| System.Object |
|
ToString()
Full OCR text discovered within this object.
A synonym of Text
.
Declaration
public override string ToString()
Returns
| Type |
Description |
| System.String |
|
Implements
IronSoftware.Abstractions.Pdf.IDocumentTextObject
IronSoftware.Abstractions.Pdf.IBoundedPdfDocumentObject
IronSoftware.Abstractions.Pdf.IPdfDocumentObject
IronSoftware.Abstractions.IDocumentObject
IronSoftware.Abstractions.IBounded
IronSoftware.ITransformable
IronSoftware.Abstractions.IColored
System.ICloneable