IronSoftware
  • Products
    for .NET Java
    Create, read, and edit PDFs
    for .NET
    Image to text in 127 languages
    for .NET
    Read and write QR & Barcodes
    for .NET
    Edit Excel & CSV Files.
    No Office Interop required
    for .NET
    Extract structured data from websites
    5 for the Price of 2 All 5 .NET product licenses from $1498 Save 60% with Iron Suite Iron Suites - Donate $50
  • Open Source
    for .NET
    System.Drawing.Common Replacement
  • About Us
  • Contact Us

205 N. Michigan Ave. Chicago, IL 60611, USA +1 (312) 500-3060

Join Iron Slack

  • Home
  • Licensing
  • EULA
  • Support & Update Extensions
  • License Upgrades
  • Start 30-Day Trial
  • Features
  • Get Started
  • Languages
  • Code Examples
  • Tutorials
  • How-Tos
  • Troubleshooting
  • Product Updates
  • API Reference
  • Search
  • Free NuGet Download
IronOCR Library for C# IronOCR Library for C#
  • Home
  • Licensing
    • Licensing
    • EULA
    • Support & Update Extensions
    • License Upgrades
    • Start 30-Day Trial
  • Features
  • Docs
    • Search
    • Get Started
    • Languages
    • Code Examples
    • Tutorials
    • How-Tos
    • Troubleshooting
    • Product Updates
    • API Reference
    • Search
  • Search
  • Free NuGet Download Total downloads: 732,945
Message's icon

PDF OCR for C#

  1. Extends PDF capabilities of Tesseract for C#
  2. Read text & barcode (OCR) PDFs in C#
  3. Supports C# and VB.NET
Free NuGet Download Total downloads: 732,945 Free 30-Day Trial Key Total downloads: 732,945
Start for Free Total downloads: 732,945

Or download the DLL directly here

Examples

  • OCR in 1 line of code
  • PDF OCR Text Extraction
  • OCR with Barcode & QR Reading
  • 125 International OCR Languages
  • Fixing Low Quality Scans & Images
  • Fast OCR Configuration
  • OCR Image Optimization Filters
  • OcrResult Class
  • Create Searchable PDFs by OCR
  • Tesseract 5 for .NET
See All 24 Code Examples
OCR in 1 line of code See All 24 Code Examples
// NuGet PM> Install-Package IronOcr
using IronOcr;

string imageText = new IronTesseract().Read(@"images\image.png").Text;
Install-Package IronOcr
PDF OCR Text Extraction See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

using (var ocrInput = new OcrInput())
{
    // OCR entire document
    ocrInput.AddPdf("example.pdf", "password");

    // Alternatively OCR selected page numbers
    ocrInput.AddPdfPages("example.pdf", new[] { 1, 2, 3 }, "password");

    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
OCR with Barcode & QR Reading See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
using (var ocrInput = new OcrInput(@"images\imageWithBarcode.png"))
{
    var ocrResult = ocrTesseract.Read(ocrInput);
    foreach (var barcode in ocrResult.Barcodes)
    {
        Console.WriteLine(barcode.Value);
    }
}
Install-Package IronOcr
125 International OCR Languages See All 24 Code Examples
//PM> Install-Package IronOcr.Languages.Arabic
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

ocrTesseract.Language = OcrLanguage.Arabic;

using (var ocrInput = new OcrInput(@"images\arabic.gif"))
{
    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}

// Example with a Custom Trained Font Being used:

var ocrTesseractCustomerLang = new IronTesseract();
ocrTesseractCustomerLang.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");
ocrTesseractCustomerLang.AddSecondaryLanguage(OcrLanguage.EnglishBest);

using (var ocrInput = new OcrInput(@"images\mixed-lang.pdf"))
{
    var ocrResult = ocrTesseractCustomerLang.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
Fixing Low Quality Scans & Images See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();
using (var ocrInput = new OcrInput(@"images\image.png"))
{
    ocrInput.Deskew();
    ocrInput.DeNoise();
    ocrInput.Despeckle();
    ocrInput.EnhanceResolution(225);
    ocrInput.Sharpen();
    ocrInput.Erode();
    ocrInput.Dilate();
    ocrInput.Scale(200);
    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
Fast OCR Configuration See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

// Fast Dictionary
ocrTesseract.Language = OcrLanguage.EnglishFast;

// Turn off unneeded options
ocrTesseract.Configuration.ReadBarCodes = false;
ocrTesseract.Configuration.RenderSearchablePdfsAndHocr = false;

// Assume text is laid out neatly in an orthogonal document
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto;

using (var ocrInput = new OcrInput(@"images\image.png"))
{
    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
OCR Image Optimization Filters See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();
using (var ocrInput = new OcrInput(@"images\image.png"))
{
    // Note: You don't need all of them; most users only need Deskew() and occasionally DeNoise()
    ocrInput.WithTitle("My Document");
    ocrInput.Binarize();
    ocrInput.Contrast();
    ocrInput.Deskew();
    ocrInput.DeNoise();
    ocrInput.Despeckle();
    ocrInput.Dilate();
    ocrInput.EnhanceResolution(300);
    ocrInput.Invert();
    ocrInput.Rotate(90);
    ocrInput.Scale(150);
    ocrInput.Sharpen();
    ocrInput.ToGrayScale();
    ocrInput.Erode();

    // WIZARD - If you are unsure use the debug-wizard to test all combinations:
    string codeToRun = OcrInputFilterWizard.Run(@"images\image.png", out double confidence, ocrTesseract);
    Console.WriteLine(codeToRun);

    // Optional: Export modified images so you can view them.
    foreach (var page in ocrInput.Pages)
    {
        page.SaveAsImage($"filtered_{page.Index}.bmp");
    }

    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
OcrResult Class See All 24 Code Examples
using IronOcr;
using IronSoftware.Drawing;

// We can delve deep into OCR results as an object model of
// Pages, Barcodes, Paragraphs, Lines, Words and Characters
// This allows us to explore, export and draw OCR content using other APIs/
var ocrTesseract = new IronTesseract();

ocrTesseract.Configuration.ReadBarCodes = true;

using (var ocrInput = new OcrInput(@"example.tiff"))
{
    OcrResult ocrResult = ocrTesseract.Read(ocrInput);
    foreach (var page in ocrResult.Pages)
    {
        // Page object
        int PageNumber = page.PageNumber;
        string PageText = page.Text;
        int PageWordCount = page.WordCount;
        // null if we dont set Ocr.Configuration.ReadBarCodes = true;
        OcrResult.Barcode[] Barcodes = page.Barcodes;
        AnyBitmap PageImage = page.ToBitmap(ocrInput);
        int PageWidth = page.Width;
        int PageHeight = page.Height;
        double PageRotation = page.Rotation; // angular correction in degrees from OcrInput.Deskew()

        foreach (var paragraph in page.Paragraphs)
        {
            // Pages -> Paragraphs
            int ParagraphNumber = paragraph.ParagraphNumber;
            string ParagraphText = paragraph.Text;
            AnyBitmap ParagraphImage = paragraph.ToBitmap(ocrInput);
            int ParagraphX_location = paragraph.X;
            int ParagraphY_location = paragraph.Y;
            int ParagraphWidth = paragraph.Width;
            int ParagraphHeight = paragraph.Height;
            double ParagraphOcrAccuracy = paragraph.Confidence;
            OcrResult.TextFlow paragrapthText_direction = paragraph.TextDirection;
            foreach (var line in paragraph.Lines)
            {
                // Pages -> Paragraphs -> Lines
                int LineNumber = line.LineNumber;
                string LineText = line.Text;
                AnyBitmap LineImage = line.ToBitmap(ocrInput);
                int LineX_location = line.X;
                int LineY_location = line.Y;
                int LineWidth = line.Width;
                int LineHeight = line.Height;
                double LineOcrAccuracy = line.Confidence;
                double LineSkew = line.BaselineAngle;
                double LineOffset = line.BaselineOffset;
                foreach (var word in line.Words)
                {
                    // Pages -> Paragraphs -> Lines -> Words
                    int WordNumber = word.WordNumber;
                    string WordText = word.Text;
                    AnyBitmap WordImage = word.ToBitmap(ocrInput);
                    int WordX_location = word.X;
                    int WordY_location = word.Y;
                    int WordWidth = word.Width;
                    int WordHeight = word.Height;
                    double WordOcrAccuracy = word.Confidence;
                    foreach (var character in word.Characters)
                    {
                        // Pages -> Paragraphs -> Lines -> Words -> Characters
                        int CharacterNumber = character.CharacterNumber;
                        string CharacterText = character.Text;
                        AnyBitmap CharacterImage = character.ToBitmap(ocrInput);
                        int CharacterX_location = character.X;
                        int CharacterY_location = character.Y;
                        int CharacterWidth = character.Width;
                        int CharacterHeight = character.Height;
                        double CharacterOcrAccuracy = character.Confidence;
                        // Output alternative symbols choices and their probability.
                        // Very useful for spellchecking
                        OcrResult.Choice[] Choices = character.Choices;
                    }
                }
            }
        }
    }
}
Install-Package IronOcr
Create Searchable PDFs by OCR See All 24 Code Examples
using IronOcr;

var ocrTesseract = new IronTesseract();

using (var ocrInput = new OcrInput())
{
    ocrInput.AddImage(@"images\page1.png");
    ocrInput.AddImage(@"images\page2.bmp");
    ocrInput.AddImage(@"images\page3.tiff");

    ocrInput.Deskew();

    var ocrResult = ocrTesseract.Read(ocrInput);

    ocrResult.SaveAsSearchablePdf("searchable.pdf");
}
Install-Package IronOcr
Tesseract 5 for .NET See All 24 Code Examples
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

// This is done by default and can be omitted:
// ocrTesseract.Configuration.TesseractVersion = TesseractVersion.Tesseract5;

using (var ocrInput = new OcrInput(@"images\image.png"))
{
    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Install-Package IronOcr
IronOCR

The OCR Solution for your .NET Applications...

.NET Developer Support

Human Support

Talk directly with our development team

Ask a Question
C# API Reference and Get Started Tutorials

Documentation

Clear online manuals in plain English.

View Documentation
C# Library Licensing

Simple Licensing

Free development license. Commercial from $749.

Browse Options
Install The C# OCR library

Get Started Now

Get started in minutes with NuGet or DLL.

Install & Try Now
Try IronOCR for Free
Get Set Up in 5 Minutes
C# NuGet Library for PDF
Install with NuGet
Version: 2023.3
Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL
Version: 2023.3
Download Now
or download Windows Installer here.
  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"
Licenses from $749

Have a question? Get in touch with our development team.

Now that you’ve downloaded IronOCR
Want to deploy IronOCR to a live project for FREE?
Not ready to buy?

Want to deploy IronOCR to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No restrictions in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:
Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
Your Trial License Key has been emailed to you.
Not ready to buy?
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
View Licensing
Schedule a call
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
Want to deploy IronOCR to a live project for FREE?
Not ready to buy?

Want to deploy IronOCR to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No restrictions in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:
Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
Your Trial License Key has been emailed to you.
Not ready to buy?
Download IronOCR free to apply
your Trial Licenses Key
Thank you.
If you'd like to speak to our licensing team:
Install with NuGet View Licensing
Schedule a call
Licenses from $749. Have a question? Get in touch.
Have a question? Get in touch with our development team.
Free 30-Day Trial Key

Fully-functional product, get the key instantly

IronOCR for .NET

Tesseract 5 OCR in the languages you need, We support 127+.

Search

Documentation

  • Code Examples
  • API Reference
  • How-Tos
  • Features
  • Credits
  • Blog
  • Product Brochure

Tutorials

  • Get Started
  • C# Image to Text
  • C# Tesseract OCR
  • OCR Image Filters
  • OCR with Computer Vision

Licensing

  • Buy a License
  • Support Extensions
  • Resellers
  • License Keys
  • EULA

Try IronOCR Free

  • Download on NuGet
  • Download DLL

  • Download Windows Installer

  • 30-Day Trial License

When you need your PDF to look like HTML, fast.

Tesseract 5 OCR in the languages you need, We support 127+.

When you need to read, write, and style, QR & Barcodes, fast.

The Excel API you need, without the Office Interop hassle.

The power you need to scrape & output clean, structured data.

The complete .NET Suite for your office.

  • IRONSUITE
  • |
  • IRONPDF
  • IRONOCR
  • IRONBARCODE
  • IRONXL
  • IRONWEBSCRAPER
IronSoftware
205 N. Michigan Ave. Chicago, IL 60611 USA +1 (312) 500-3060
  • About Us
  • News
  • Careers
  • Contact Us
  • Join Iron Slack

Supporting Teamseas

Copyright © Iron Software LLC 2013-2023

  • Terms
  • Privacy

Thank you!

Your license key has been delivered to the email provided. Contact us

24-Hour Upgrade Offer:

Save 50% on a
Professional Upgrade

Go Professional to cover 10 developers
and unlimited projects.

hours

:

minutes

:

seconds

Upgrade to Professional

Upgrade

Professional

$600 USD

$299 USD


  • 10 developers
  • 10 locations
  • 10 projects
TODAY ONLY
Iron Suite

5 .NET Products for the Price of 2

IronPDF IronOCR IronXL IronBarcode IronWebscraper

Total Suite Value:

$7,192 USD

Upgrade price

TODAY
ONLY

$499 USD

After 24 Hrs

$1,098 USD