# PdfOcr class

> Makes scanned PDFs searchable: finds the image that is each page's scan, reads it with an IOcrEngine, and lays the words over it as invisible text, so...

Namespace: [PdfNetStack.Ocr](https://www.jadev-corp.com/api/pdfnetstack-ocr/)  
Assembly: PdfNetStack.Ocr.dll  
Package: `PdfNetStack.Ocr`

Makes scanned PDFs searchable: finds the image that is each page's scan, reads it with an
[IOcrEngine](https://www.jadev-corp.com/api/pdfnetstack-ocr/iocrengine/), and lays the words over it as invisible text, so the page looks the
same but selects, copies and searches.

```csharp
public sealed class PdfOcr
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfOcr](https://www.jadev-corp.com/api/pdfnetstack-ocr/pdfocr/)

## Examples

<pre><code class="lang-csharp">using var engine = OnnxOcrEngine.Load();
PdfDocument doc = PdfDocument.Open("scan.pdf");
PdfOcrReport report = new PdfOcr(engine).MakeSearchable(doc);
doc.Save("scan-searchable.pdf");</code></pre>

## Constructors

### <a id="PdfNetStack_Ocr_PdfOcr__ctor_PdfNetStack_Ocr_IOcrEngine_PdfNetStack_Ocr_PdfOcrOptions_"></a> PdfOcr\(IOcrEngine, PdfOcrOptions?\)

Uses <code class="paramref">engine</code>; the caller keeps ownership and disposes it.

```csharp
public PdfOcr(IOcrEngine engine, PdfOcrOptions? options = null)
```

#### Parameters

`engine` [IOcrEngine](https://www.jadev-corp.com/api/pdfnetstack-ocr/iocrengine/)

The recognizer.

`options` [PdfOcrOptions](https://www.jadev-corp.com/api/pdfnetstack-ocr/pdfocroptions/)?

Languages, limits and skipping; defaults when null.

## Methods

### <a id="PdfNetStack_Ocr_PdfOcr_MakeSearchable_PdfNetStack_PdfDocument_System_Threading_CancellationToken_"></a> MakeSearchable\(PdfDocument, CancellationToken\)

Reads every scanned page and adds invisible text to it.

```csharp
public PdfOcrReport MakeSearchable(PdfDocument document, CancellationToken cancellationToken = default)
```

#### Parameters

`document` [PdfDocument](https://www.jadev-corp.com/api/pdfnetstack/pdfdocument/)

The document, changed in place; save it afterwards.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

Stops between pages and lines.

#### Returns

 [PdfOcrReport](https://www.jadev-corp.com/api/pdfnetstack-ocr/pdfocrreport/)

### <a id="PdfNetStack_Ocr_PdfOcr_Recognize_PdfNetStack_PdfDocument_System_Threading_CancellationToken_"></a> Recognize\(PdfDocument, CancellationToken\)

Reads every scanned page without changing the document.

```csharp
public PdfOcrReport Recognize(PdfDocument document, CancellationToken cancellationToken = default)
```

#### Parameters

`document` [PdfDocument](https://www.jadev-corp.com/api/pdfnetstack/pdfdocument/)

The document.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

Stops between pages and lines.

#### Returns

 [PdfOcrReport](https://www.jadev-corp.com/api/pdfnetstack-ocr/pdfocrreport/)

## Used in

- [Make scanned PDFs searchable with OCR in C#](https://www.jadev-corp.com/guides/ocr/)
- [Make a scanned PDF searchable in C#](https://www.jadev-corp.com/recipes/make-scanned-pdf-searchable/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-ocr/pdfocr/
