Class OcrReadOptions
Limits for reading hOCR and ALTO files, which may come from an untrusted engine or file.
public sealed record OcrReadOptions : IEquatable<OcrReadOptions>
- Inheritance
-
OcrReadOptions
- Implements
- Inherited Members
Examples
// Read hOCR from Tesseract or any other engine, under limits for files you did not make.
using FileStream file = File.OpenRead("page.hocr");
IReadOnlyList<OcrResult> pages = Hocr.Read(file, new OcrReadOptions { MaxWords = 100_000 });
Console.WriteLine($"{pages.Count} page, {pages[0].Words.Count()} words: {pages[0].Lines[0].Text}");
// Write results back as hOCR (or Alto.Write for ALTO).
using FileStream copy = File.Create("copy.hocr");
Hocr.Write(copy, pages);
Properties
Default
Gets the default options.
public static OcrReadOptions Default { get; }
Property Value
Dpi
Gets the resolution, in pixels per inch, that turns ALTO positions in 1/10 mm or 1/1200 inch into pixels. Defaults to 300.
public double Dpi { get; init; }
Property Value
MaxBytes
Gets the largest file, in bytes. Defaults to 256 MB.
public long MaxBytes { get; init; }
Property Value
MaxWords
Gets the most words in one file, over all pages. Defaults to 4,000,000.
public int MaxWords { get; init; }