Read Scanned Documents in C# Using IronOCR
IronOCR enables C# developers to extract text from scanned PDFs and images using OCR technology, converting non-searchable image-based documents into searchable, accessible content with just a few lines of code.
Many PDFs contain non-searchable, image-based text. IronOCR converts this into searchable content, making it easier to locate specific information and enhancing document accessibility, especially for individuals with visual impairments.
Instead of manually copying or recreating text and images, automated extraction ensures accuracy and efficiency. This is particularly useful for research, legal documents, and content creation where reusing specific portions of PDFs is common.
Businesses can extract critical data from PDFs for analysis or system integration, streamlining workflows. Designers and marketers can also extract images for enhancement and reuse in various projects.
In this tutorial, we'll explore the OcrPdfInput methods, covering the available options and parameters to showcase how IronOCR simplifies PDF text and image extraction for various applications.
To use this function, you must also install the IronOcr.Extensions.AdvancedScan package.
Get started in seconds - with one line of code you'll load your scanned PDF or image using IronOCR's OcrInput.LoadPdf or LoadImage and instantly extract the text via ReadDocument. Perfect for developers who want OCR up and running fast.
-
1Install IronOCR with NuGet Package Manager
-
2Copy and run this code snippet.
var text = new IronOcr.IronTesseract().ReadDocument(new IronOcr.OcrInput().LoadPdf("scanned.pdf")).Text;C# -
3Deploy to test on your live environment
Start using IronOCR in your project today with a free trial
Minimal Workflow (5 steps)
- Download the C# library for reading scanned documents
- Import the scanned document for processing
- Use the
LoadImagemethod for images orLoadPdffor scanned PDFs - Extract text using the
ReadDocumentmethod - Save or export the extracted text as needed for further use
How Do I Extract Text from Scanned Documents?
To extract text from all images within a document, use the ReadDocument method. This method processes the document and returns an object containing the extracted text, which can be accessed through the Text property. The example below demonstrates how to use this method with a sample TIFF file.
IronOCR supports a wide variety of document formats for scanning. For images, you can work with JPG, PNG, GIF, TIFF, and BMP formats, while PDF support includes both single and multi-page documents. The library uses advanced Tesseract 5 technology to ensure high accuracy across all supported formats.
What Does the Input Document Look Like?

What Do I Implement the OCR Code?
using IronOcr;
using System;
// Instantiate OCR engine
var ocr = new IronTesseract();
// Configure OCR engine
using var input = new OcrInput();
input.LoadImage("potter.tiff");
// Perform OCR
OcrResult result = ocr.ReadDocument(input);
Console.WriteLine(result.Text);Imports IronOcr
Imports System
' Instantiate OCR engine
Dim ocr As New IronTesseract()
' Configure OCR engine
Using input As New OcrInput()
input.LoadImage("potter.tiff")
' Perform OCR
Dim result As OcrResult = ocr.ReadDocument(input)
Console.WriteLine(result.Text)
End UsingWhat Results Can I Expect from OCR Processing?

If you need to perform OCR on a PDF file instead, simply replace the LoadImage method with LoadPdf. This allows IronOCR to process and extract text from scanned PDFs in the same way.
Advanced Document Processing Options
When working with scanned documents, you often need more control over the OCR process. IronOCR provides several advanced features to enhance your text extraction results.
Processing Multi-Page Documents
For documents with multiple pages, IronOCR efficiently handles batch processing:
using IronOcr;
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load a multi-page PDF
input.LoadPdf("multi-page-document.pdf");
// Process all pages
OcrResult result = ocr.ReadDocument(input);
// Access individual page results
foreach (var page in result.Pages)
{
Console.WriteLine($"Page {page.PageNumber}: {page.WordCount} words");
}
Optimizing OCR Performance
The quality of your scanned documents directly impacts OCR accuracy. IronOCR includes built-in image optimization filters to enhance text recognition:
using IronOcr;
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load and enhance image quality
input.LoadImage("low-quality-scan.jpg");
input.Deskew(); // Correct image skew
input.DeNoise(); // Remove background noise
input.Binarize(); // Convert to black and white
OcrResult result = ocr.ReadDocument(input);Imports IronOcr
Dim ocr As New IronTesseract()
Using input As New OcrInput()
' Load and enhance image quality
input.LoadImage("low-quality-scan.jpg")
input.Deskew() ' Correct image skew
input.DeNoise() ' Remove background noise
input.Binarize() ' Convert to black and white
Dim result As OcrResult = ocr.ReadDocument(input)
End UsingCreating Searchable PDFs
One of the most valuable features when processing scanned documents is the ability to create searchable PDFs. This maintains the original document appearance while adding a text layer:
using IronOcr;
var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadPdf("scanned-document.pdf");
// Process and save as searchable PDF
OcrResult result = ocr.ReadDocument(input);
result.SaveAsSearchablePdf("searchable-output.pdf");Imports IronOcr
Dim ocr As New IronTesseract()
Using input As New OcrInput()
input.LoadPdf("scanned-document.pdf")
' Process and save as searchable PDF
Dim result As OcrResult = ocr.ReadDocument(input)
result.SaveAsSearchablePdf("searchable-output.pdf")
End UsingWorking with Different Document Types
IronOCR excels at processing various document types commonly encountered in business environments. Whether you're dealing with invoices, contracts, or historical documents, the library provides specialized features for extracting data from different sources.
Processing Legacy Documents
Many organizations have archives of scanned documents in older formats. IronOCR handles these efficiently, including support for multi-page TIFF files commonly used in document management systems.
Language Support
While this example focuses on English text, IronOCR supports over 125 international languages. This makes it ideal for processing multilingual documents or documents in non-English languages.
Best Practices for Document Scanning
To achieve optimal results when processing scanned documents:
- Scan Quality: Use a minimum resolution of 300 DPI for best results
- File Format: TIFF and PNG formats preserve quality better than JPEG for text documents
- Pre-processing: Apply appropriate filters based on your document condition
- Performance: For large batches, consider using multithreading capabilities
Troubleshooting Common Issues
When working with scanned documents, you might encounter various challenges. Here are solutions to common problems:
- Poor quality scans: Apply enhancement filters before OCR processing
- Skewed documents: Use the
Deskew()method to correct orientation - Mixed content: Process specific regions if documents contain both text and non-text elements
For more detailed guidance, explore our comprehensive C# OCR tutorial or check out simple OCR examples to get started quickly.
Next Steps
Now that you understand how to extract text from scanned documents, you can explore more advanced features like making any PDF searchable or processing PDF streams for web applications. IronOCR's flexibility makes it suitable for everything from simple document digitization to complex enterprise document processing workflows.
Frequently Asked Questions
How can I extract text from scanned PDFs using IronOCR?
Using IronOCR, you can extract text by loading your scanned PDF using methods like `OcrInput.LoadPdf` and then calling the `ReadDocument()` method. This allows you to convert non-searchable PDFs into text-readable formats.
What image formats can IronOCR process?
IronOCR supports a variety of image formats such as JPG, PNG, GIF, TIFF, and BMP, enabling text extraction from a wide range of document types.
What is the `ReadDocument` method in IronOCR used for?
The `ReadDocument` method processes the loaded document and extracts text from all images within it, making that text accessible via the `Text` property of the resulting object.
Can IronOCR handle multi-page documents?
Yes, IronOCR can efficiently process multi-page documents, such as PDFs, by loading them with the `LoadPdf` method and extracting text from each page.
How can I enhance the quality of scanned images for better OCR results?
IronOCR includes image optimization filters like `Deskew`, `DeNoise`, and `Binarize`, which can improve OCR accuracy by correcting image skew, removing background noise, and converting images to black and white.
Does IronOCR support extracting text from documents in different languages?
IronOCR supports over 125 languages, making it adaptable for processing multilingual or non-English documents efficiently.
What does IronOCR offer for creating searchable PDFs?
With IronOCR, you can convert scanned documents into searchable PDFs by processing the document and saving it with the text layer intact, thereby maintaining its original appearance while adding search functionality.
What package is required for advanced OCR features in IronOCR?
To access advanced OCR features in IronOCR, you need to install the `IronOcr.Extensions.AdvancedScan` package, which adds additional capabilities for document processing.
What are the best practices for scanning documents for OCR processing?
For optimal OCR results, use a minimum resolution of 300 DPI, save documents in TIFF or PNG formats, apply pre-processing filters if needed, and utilize multithreading for processing large batches.
How does IronOCR handle poor quality scans?
IronOCR can improve OCR results for poor quality scans by using enhancement filters like `DeNoise` to clean up the image and `Deskew` to correct any orientation issues before processing.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.