Class OcrResult
A full document object model (DOM) for results when IronTesseract reads an image or OcrInput.
Gives access to Text, Pages, Words, Paragraphs, Lines, Words, Characters, Images, Barcodes, Coordinates, Font information in granular detail.
Inheritance
Namespace: IronOcr
Assembly: IronOcr.dll
Syntax
public class OcrResult : Object
Properties
Barcodes
Represents every barcode discovered in this OCR document. Developers must set ReadBarCodes = True for this feature to be active.
Declaration
public OcrResult.Barcode[] Barcodes { get; }
Property Value
Type | Description |
---|---|
OcrResult.Barcode[] |
Blocks
Represents every block of text discovered in this OCR document in order of appearance. A Block is a collection of 1 or more paragraphs located closely together.
Declaration
public OcrResult.Block[] Blocks { get; }
Property Value
Type | Description |
---|---|
OcrResult.Block[] |
Cancelled
Indicates that the Ocr reading was cancelled by the user or after a timeout
Declaration
public bool Cancelled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Characters
Represents every symbol (char) discovered in this OCR document in order of appearance.
Declaration
public OcrResult.Character[] Characters { get; }
Property Value
Type | Description |
---|---|
OcrResult.Character[] |
Confidence
OCR statistical accuracy confidence as an average of every character.
1 = 100%, 0 = 0%
Declaration
public double Confidence { get; }
Property Value
Type | Description |
---|---|
System.Double |
EngineModeUsed
The TesseractEngineMode used to generate this OcrResult.
Declaration
public TesseractEngineMode EngineModeUsed { get; }
Property Value
Type | Description |
---|---|
TesseractEngineMode |
See Also
Lines
Represents every line of text discovered in this OCR document in order of appearance.
Declaration
public OcrResult.Line[] Lines { get; }
Property Value
Type | Description |
---|---|
OcrResult.Line[] |
Pages
Represents every page within this OcrResult object.
Declaration
public OcrResult.Page[] Pages { get; }
Property Value
Type | Description |
---|---|
OcrResult.Page[] |
Paragraphs
Represents every paragraph of text discovered in this OCR document in order of appearance.
Declaration
public OcrResult.Paragraph[] Paragraphs { get; }
Property Value
Type | Description |
---|---|
OcrResult.Paragraph[] |
TesseractVersion
The TesseractVersion used to generate this OcrResult.
Declaration
public string TesseractVersion { get; }
Property Value
Type | Description |
---|---|
System.String |
See Also
Text
Returns the entire Text content of this OCR document. 4 System.Environment.NewLine characters will separate pages.
Declaration
public string Text { get; }
Property Value
Type | Description |
---|---|
System.String |
Words
Represents every word discovered in this OCR document in order of appearance.
Declaration
public OcrResult.Word[] Words { get; }
Property Value
Type | Description |
---|---|
OcrResult.Word[] |
Methods
FromJson(String)
Deserializes the JSON to the OcrResult object.
Declaration
public static OcrResult FromJson(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | A JSON string representation of the OcrResult. |
Returns
Type | Description |
---|---|
OcrResult | The deserialized OcrResult object from the JSON string. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
FromJsonFile(String)
Deserializes the JSON file to the OcrResult object.
Declaration
public OcrResult FromJsonFile(string Path)
Parameters
Type | Name | Description |
---|---|---|
System.String | Path |
Returns
Type | Description |
---|---|
OcrResult |
Remarks
Use the method FromJson(String) instead if you want deserialize from a JSON string.
SaveAsHocrFile(String)
Exports an hOCR version of the Tesseract results object document. This is an XHTML file which can be read as XML or HTML.
https://en.wikipedia.org/wiki/HOCR
Declaration
public void SaveAsHocrFile(string Path)
Parameters
Type | Name | Description |
---|---|---|
System.String | Path | The file path the xhtml file will be saved to. |
SaveAsHocrString()
Exports an hOCR version of the Tesseract results object document as a string. This is an XHTML file which can be read as XML or HTML.
https://en.wikipedia.org/wiki/HOCR
Declaration
public string SaveAsHocrString()
Returns
Type | Description |
---|---|
System.String |
SaveAsSearchablePdf(String)
Exports a searchable PDF version of the OCR input document. Works for all input formats including PDFs & Images.
Declaration
public void SaveAsSearchablePdf(string Path)
Parameters
Type | Name | Description |
---|---|---|
System.String | Path | The file path the PDF will be saved to. |
SaveAsSearchablePdfBytes()
Exports a searchable PDF version of the OCR input document as a byte array. Works for all input formats including PDFs & Images.
Declaration
public byte[] SaveAsSearchablePdfBytes()
Returns
Type | Description |
---|---|
System.Byte[] |
SaveAsSearchablePdfStream()
Exports a searchable PDF version of the OCR input document as a Stream. Works for all input formats including PDFs & Images.
Declaration
public Stream SaveAsSearchablePdfStream()
Returns
Type | Description |
---|---|
System.IO.Stream |
SaveAsTextFile(String)
Exports a .txt version of the Tesseract results objects document. This is a plain text file.
4 Environment.Newlines between pages. 2 Environment.Newlines between paragraphs.
Declaration
public void SaveAsTextFile(string Path)
Parameters
Type | Name | Description |
---|---|---|
System.String | Path | The file path the text file will be saved to. |
SaveJsonAs(String)
Serializes the OcrResult object to a JSON file..
Declaration
public void SaveJsonAs(string Path)
Parameters
Type | Name | Description |
---|---|---|
System.String | Path |
Remarks
Use the method ToJson() instead if you want to get the string instead of saving to disk.
ToJson()
Serializes the OcrResult object to a JSON string.
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String | The JSON string representation of the OcrResult. |
Remarks
Use the method FromJson(String) for deserializing the JSON to the OcrResult object.