---
title: "Set the DPI for PDF OCR in C#"
url: https://recursiveai.org/oneocr/cookbook/set-pdf-ocr-render-dpi/
description: "Set the render resolution for PDF OCR in C# with PdfOcrOptions.RenderDpi. See how 150 and 400 DPI change the reading of small print."
version: "1.1.0"
---

# Set the DPI for PDF OCR in C#

**OneOcr** is a free, open-source OCR library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneOcr.Pdf) · [GitHub](https://github.com/recursive-ai-oss/oneocr-csharp) · [Docs](https://recursiveai.org/oneocr/docs/) · [Download example (.zip)](https://recursiveai.org/oneocr/cookbook/set-pdf-ocr-render-dpi/set-pdf-ocr-render-dpi.zip)

Set `RenderDpi` to read the small print in `scan.pdf` from the zip: “Check the west shelf.”

```shell
dotnet add package RecursiveAI.OneOcr.Pdf
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneOcr;
using OneOcr.Pdf;
var engine = OcrEngine.LoadBundled();
var options = new PdfOcrOptions
{ RenderDpi = 400 };
var page = PdfOcr.Read(
    "scan.pdf", engine, options)[0];
Console.WriteLine(page.ToText());
```

Unzip [the example](https://recursiveai.org/oneocr/cookbook/set-pdf-ocr-render-dpi/set-pdf-ocr-render-dpi.zip), then `dotnet run`.

At 400 DPI, both lines read correctly:

```text
Warehouse inventory
Check the west shelf
```

## The full program

The single-page sample is an image of “Warehouse inventory” with a 7-point note below it. At 150 DPI, the last word is wrong; at 400 DPI, OneOcr reads “shelf.”

```csharp
using OneOcr;
using OneOcr.Pdf;

var engine = OcrEngine.LoadBundled();
foreach (int dpi in new[] { 150, 400 })
{
    var options = new PdfOcrOptions { RenderDpi = dpi };
    var page = PdfOcr.Read("scan.pdf", engine, options)[0];
    Console.WriteLine(page.ToText());
    foreach (var note in page.Diagnostics)
        Console.WriteLine(note);
}
```

```text
Warehouse inventory
Check the west shet
OCR301: 1 regions were read from pixels at 150 DPI (6 words).
Warehouse inventory
Check the west shelf
OCR301: 1 regions were read from pixels at 400 DPI (6 words).
```

`RenderDpi` must be between 72 and 1200, inclusive, or the reader throws `ArgumentException`. A DPI in that range can still make a large page exceed the pixel limit; check `page.Diagnostics` for regions that couldn’t be read.

## Variations

**Try the default resolution.** Replace the options declaration in the snippet at the top. On the sample, 300 DPI also reads both lines correctly.

```csharp
var options = new PdfOcrOptions(); // 300 DPI
```

## Related recipes

- [Extract text from a scanned PDF](https://recursiveai.org/oneocr/cookbook/ocr-pdf/)
- [Map OCR boxes to PDF page coordinates](https://recursiveai.org/oneocr/cookbook/map-ocr-boxes-to-pdf-page-coordinates/)
- [Fail when PDF OCR can’t read a region](https://recursiveai.org/oneocr/cookbook/fail-on-incomplete-pdf-ocr/)

## The short answer

Set `PdfOcrOptions.RenderDpi` before calling `PdfOcr.Read`. It defaults to 300 dots per inch (DPI) and controls the resolution of the rendered pixels used for recognition. It doesn’t change your scanner settings, rewrite the PDF, or recover detail that wasn’t captured in the original scan.

## What resolution should I use for scanned PDF OCR?

Start with the default of 300 DPI. Try a different value on pages that represent the documents you actually need to read. Compare the extracted words against the page image, especially small print and fields with digits. In this sample, the smaller line is misread at 150 DPI, but 300 DPI is already enough to read it correctly.

The [PDF bridge](https://recursiveai.org/oneocr/docs/pdf-bridge/#what-is-read-how) crops regions from the rendered page and maps results back to points. For the same page size, doubling the render DPI roughly doubles both pixel dimensions, which means about four times as many pixels. Lower DPI means fewer pixels to process and less memory for the render, but small letters can lose detail. Higher DPI can make small print readable, at the cost of more processing and memory; on large pages it can make the render exceed the pixel limit. It’s more useful to check diagnostics and the actual text than to pick the highest allowed DPI.

## Can increasing DPI fix a blurry PDF scan?

Increasing `RenderDpi` changes how the PDF is drawn for recognition. If the original scan has more detail than the lower-resolution render preserved, the recognizer sees more of what the file contains. But a larger render of an already blurry image can’t restore missing letter shapes. If you can still access the paper, rescanning and changing render DPI are two different things to try.

On PDFs with usable selectable text, OneOcr can return text from the file itself instead of recognizing it from pixels. Check each word’s `Source`: `Ocr` means it came from recognition, while `TextLayer` means it came from the PDF’s accepted text. DPI is a setting for the rendered input, not a way to rescale the output coordinates or edit that existing text layer.
