Set RenderDpi to read the small print in scan.pdf from the zip: “Check the west shelf.”
dotnet add package RecursiveAI.OneOcr.PdfRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
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, then dotnet run.
At 400 DPI, both lines read correctly:
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.”
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); }
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.
var options = new PdfOcrOptions(); // 300 DPIRelated recipes
- Extract text from a scanned PDF
- Map OCR boxes to PDF page coordinates
- Fail when PDF OCR can’t read a region
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 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.