Features Overview
Features Overview
This page introduces the library’s recognition API and the capabilities covered in depth
elsewhere in this guide. AsposeOcr is the entry point for the entire library. Its
Recognize() method accepts an
OcrInput and returns an OcrOutput — a list of RecognitionResult, one per image or PDF
page.
Single-Image and PDF Recognition
OcrInput is constructed with an InputType — InputType.SingleImage for a raster image, or
InputType.PDF for a PDF document. Files are queued with OcrInput.Add(). Disposing
OcrInput only clears the queued file paths it holds.
using Aspose.OCR;
var api = new AsposeOcr();
using var input = new OcrInput(InputType.PDF);
input.Add("document.pdf");
OcrOutput output = api.Recognize(input);Recognition Results
Each RecognitionResult exposes RecognitionText (the full recognized page text) and
RecognitionLinesResult (a list of RecognitionResult.LinesResult, each with TextInLine and
a System.Drawing.Rectangle bounding box in Line).
foreach (RecognitionResult page in output)
{
Console.WriteLine(page.RecognitionText);
foreach (RecognitionResult.LinesResult line in page.RecognitionLinesResult)
{
Console.WriteLine($"{line.Line}: {line.TextInLine}");
}
}Batch Processing
OcrInput accepts more than one file of the same input type. OcrOutput preserves the order
the files were added in, with one RecognitionResult per file (or per PDF page).
using var input = new OcrInput(InputType.SingleImage);
input.Add("page-1.jpg");
input.Add("page-2.png");
OcrOutput output = api.Recognize(input);Tips and Best Practices
- Dispose
OcrInput(or wrap it in ausingstatement) once recognition is complete to release the underlying resources. - Only
InputType.SingleImageandInputType.PDFare supported — any other input type throwsNotSupportedException. - Recognition is Latin-script only; there is no language-selection parameter.
- PDF pages are rendered internally before recognition, so no separate PDF-to-image conversion step is needed.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
NotSupportedException on Recognize() | An OcrInput was constructed with an unsupported InputType | Use only InputType.SingleImage or InputType.PDF |
FileNotFoundException on Recognize() | A path added via OcrInput.Add() does not exist | Verify the file path before calling Add() |
Empty RecognitionLinesResult | No text line was detected in that image or page | Confirm the source image contains legible, non-rotated Latin-script text |
FAQ
What languages does Aspose.OCR FOSS for .NET recognize?
Latin-script text. The embedded recognition model does not cover non-Latin scripts.
Does it require an internet connection?
No. All three ONNX models (detection, refinement, recognition) are embedded in the assembly
and run locally through Microsoft.ML.OnnxRuntime.
Can I recognize multiple files in one call?
Yes — add multiple files to the same OcrInput before calling AsposeOcr.Recognize(). The
returned OcrOutput preserves their order.
What platforms does this run on?
It targets .NET Standard 2.0, .NET Framework 4.8, and .NET 8.0+. Image processing requires
Windows, because it depends on System.Drawing.Common.
API Reference Summary
| Class/Method | Description |
|---|---|
AsposeOcr.Recognize(OcrInput) | Entry point: recognizes text and returns an OcrOutput |
OcrInput.Add(string) | Queues a file path for recognition |
InputType | Enum: SingleImage or PDF |
RecognitionResult.RecognitionText | Full recognized page text |
RecognitionResult.RecognitionLinesResult | List of recognized lines with bounding boxes |
RecognitionResult.LinesResult.TextInLine | Recognized text for one line |
RecognitionResult.LinesResult.Line | Pixel-coordinate bounding box for one line |