Microsoft.ML.OnnxRuntime; no model download and no network call
are needed at runtime. The API is centered on AsposeOcr.Recognize(), which accepts an
OcrInput built from one or more files (InputType.SingleImage or InputType.PDF) and
returns an OcrOutput — one RecognitionResult per image or PDF page, in source order.
Each RecognitionResult exposes the complete page text through RecognitionText and the
individual recognized lines, each with its pixel-coordinate bounding box, through
RecognitionLinesResult. PDF pages are rendered internally (via Aspose.PDF.FOSS) before
recognition, so no separate PDF-to-image conversion step is needed. Aspose.OCR FOSS for
.NET is MIT licensed. Install it with dotnet add package Aspose.OCR.FOSS. For the
enterprise product family, see
Aspose.OCR — Enterprise Product Family.AsposeOcr.Recognize(OcrInput) is the single entry point for both images and PDFsOcrInput accepts InputType.SingleImage or InputType.PDF; add one or more file
paths with OcrInput.Add()InputType.PDF, every page is recognized and returned in source orderOcrOutput — one RecognitionResult per image or PDF pageRecognitionResult.RecognitionText returns the full recognized page textRecognitionResult.RecognitionLinesResult returns one RecognitionResult.LinesResult
per detected text lineRecognitionResult.LinesResult.TextInLine holds that line’s recognized textRecognitionResult.LinesResult.Line is a System.Drawing.Rectangle giving the
line’s pixel coordinates in the source imageMicrosoft.ML.OnnxRuntimeOcrInput can hold multiple files; OcrOutput preserves their original orderInputType.SingleImage and InputType.PDF only — any other
input type throws NotSupportedExceptionRecognize every page of a PDF and print each page’s text in source order.
using Aspose.OCR;
var api = new AsposeOcr();
using var input = new OcrInput(InputType.PDF);
input.Add("document.pdf");
OcrOutput output = api.Recognize(input);
foreach (RecognitionResult page in output)
{
Console.WriteLine(page.RecognitionText);
}
Recognize a single raster image and print its recognized text.
using Aspose.OCR;
var api = new AsposeOcr();
using var input = new OcrInput(InputType.SingleImage);
input.Add("scan.png");
RecognitionResult result = api.Recognize(input)[0];
Console.WriteLine(result.RecognitionText);
Iterate the recognized lines and print each line’s text with its pixel coordinates.
using Aspose.OCR;
var api = new AsposeOcr();
using var input = new OcrInput(InputType.SingleImage);
input.Add("document.jpg");
RecognitionResult result = api.Recognize(input)[0];
foreach (RecognitionResult.LinesResult line in result.RecognitionLinesResult)
{
System.Drawing.Rectangle bounds = line.Line;
Console.WriteLine($"x={bounds.X}, y={bounds.Y}, width={bounds.Width}, height={bounds.Height}: {line.TextInLine}");
}
Aspose.OCR FOSS for .NET is MIT licensed. You can use, modify, and redistribute it, including in commercial products, without additional licensing fees.
See the install section above for the current install command.
Latin-script text. There is no language-selection parameter, and non-Latin scripts are not covered by the embedded recognition model.
No. All three ONNX models (detection, refinement, recognition) are embedded in the assembly and run locally through Microsoft.ML.OnnxRuntime.
Yes — add multiple files to the same OcrInput before calling AsposeOcr.Recognize(). The returned OcrOutput preserves their order.