Class OcrResult.Block
Represents a block of text containing zero or more paragraphs.
Implements
Inherited Members
Namespace: IronOcr
Assembly: IronOcr.dll
Syntax
public class Block : OcrResult.OcrResultTextElement
Grouping recognized text into the largest layout regions on a page runs through OcrResult.Block, a block holding zero or more paragraphs. It is the coarsest text element below the page itself, so it is where you start when you want output organized by column or region before drilling into paragraphs, lines, and words.
You obtain blocks by walking an OcrResult from IronTesseract.Read: read the Blocks on a page, then move down through each block's structure. The block carries the inherited Text and Confidence from OcrResult.OcrResultTextElement, plus BlockNumber, a unique one-based ID within the result, and BlockType, a string naming the kind of region the engine detected.
To descend the tree, a block exposes four arrays in order of appearance: Paragraphs, Lines, Words, and Characters. Read Paragraphs when you want the next structural level, or jump straight to Words or Characters when you only need the flattened content of the block. The inherited geometry locates the block on the page when you need to crop or draw it.
The working with OCR results how-to walks the result tree from blocks down to words, and the results objects example reads block-level structure from a scan.
Properties
BlockNumber
A unique ID for this Block within its OcrResult object. The first block will be numbered 1.
Declaration
public int BlockNumber { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
BlockType
A string representation of the type of block.
See https://github.com/charlesw/tesseract/blob/master/src/Tesseract/PolyBlockType.cs
Declaration
public string BlockType { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Characters
Every character of text within this block - in order.
Declaration
public OcrResult.Character[] Characters { get; }
Property Value
| Type | Description |
|---|---|
| OcrResult.Character[] |
Lines
Every line of text within this block.
Declaration
public OcrResult.Line[] Lines { get; }
Property Value
| Type | Description |
|---|---|
| OcrResult.Line[] |
Paragraphs
Every paragraph of text within this block.
Declaration
public OcrResult.Paragraph[] Paragraphs { get; }
Property Value
| Type | Description |
|---|---|
| OcrResult.Paragraph[] |
Words
Every word of text within this block - in order.
Declaration
public OcrResult.Word[] Words { get; }
Property Value
| Type | Description |
|---|---|
| OcrResult.Word[] |