---
Product: ocr
Platform: net
Page Type: index
Canonical URL: https://products.aspose.org/ocr/net/
---

# Aspose.OCR FOSS for .NET

Open-source .NET library for detecting and recognizing text in images and PDF
documents. MIT licensed, runs offline with embedded ONNX models.

Aspose.OCR FOSS for .NET is a free, MIT-licensed C# library that detects and recognizes text in raster images and PDF documents using embedded ONNX models — no external OCR service or network access required.

## Open-Source .NET Library for Text Detection and Recognition

Aspose.OCR FOSS for .NET is a free, MIT-licensed C# library for detecting and recognizing
text in raster images and PDF documents, without requiring external OCR software or
services. The entire pipeline — text-line detection, region refinement, and Latin-script
recognition — runs locally through three ONNX models embedded directly in the assembly and
executed on the CPU via `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](https://products.aspose.com/ocr/).

## Recognize Text in Images and PDFs

- `AsposeOcr.Recognize(OcrInput)` is the single entry point for both images and PDFs
- `OcrInput` accepts `InputType.SingleImage` or `InputType.PDF`; add one or more file
  paths with `OcrInput.Add()`
- For `InputType.PDF`, every page is recognized and returned in source order
- The result is an `OcrOutput` — one `RecognitionResult` per image or PDF page

## Where Text Recognition Is Used

- Digitizing scanned documents into searchable, copyable text
- Extracting text from scanned PDFs that have no embedded text layer
- Processing scanned forms, receipts, and invoices in a batch pipeline
- Indexing large archives of scanned images for full-text search

## Line-Level Text and Bounding Boxes

- `RecognitionResult.RecognitionText` returns the full recognized page text
- `RecognitionResult.RecognitionLinesResult` returns one `RecognitionResult.LinesResult`
  per detected text line
- Each `RecognitionResult.LinesResult.TextInLine` holds that line's recognized text
- Each `RecognitionResult.LinesResult.Line` is a `System.Drawing.Rectangle` giving the
  line's pixel coordinates in the source image

## Where Line-Level Data Is Used

- Drawing recognized-region overlays on top of the source image
- Building a searchable text layer positioned over a scanned page
- Reviewing per-line recognition accuracy during QA
- Driving redaction or annotation tooling from line coordinates

## Runs Fully Offline, No External Service

- All three ONNX models (detection, refinement, Latin recognition) are embedded assembly
  resources — nothing to download separately
- Recognition runs entirely on the local CPU through `Microsoft.ML.OnnxRuntime`
- `OcrInput` can hold multiple files; `OcrOutput` preserves their original order
- Supported input types are `InputType.SingleImage` and `InputType.PDF` only — any other
  input type throws `NotSupportedException`

## Where Offline Recognition Matters

- Air-gapped or regulated environments where documents cannot leave the network
- CI/CD pipelines without external network access during the build
- High-volume batch recognition where per-call cloud OCR pricing is a concern
- On-premises document processing with predictable, local-only latency

## Recognize Text in a PDF Document

Recognize every page of a PDF and print each page's text in source order.

```csharp
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 Text in a Single Image

Recognize a single raster image and print its recognized text.

```csharp
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);
```

## Read Recognized Lines and Their Bounding Boxes

Iterate the recognized lines and print each line's text with its pixel coordinates.

```csharp
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}");
}
```

## Frequently Asked Questions

### What is the licensing model?

Aspose.OCR FOSS for .NET is MIT licensed. You can use, modify, and redistribute it, including in commercial products, without additional licensing fees.

### How do I install Aspose.OCR FOSS for .NET?

See the install section above for the current install command.

### What languages does it recognize?

Latin-script text. There is no language-selection parameter, and non-Latin scripts are not covered by the embedded recognition model.

### 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.

## Support and Learning Resources

- [Documentation](https://docs.aspose.org/ocr/net/)
- [API References](https://reference.aspose.org/ocr/net/)
- [Free Support](https://forum.aspose.org/)
- [Contribution](https://contribution.aspose.org/)
- [Blog](https://blog.aspose.org/)
- [New Releases](https://releases.aspose.org/)