The C# OCR Library

IronOcr makes it easy to read text from images in your .net apps & websites.

  • # Read text and barcodes from scanned images & PDFs
  • # Supports multiple international languages
  • # Output as plain text or structured data

C# OCR

Image to Text & PDF to Text OCR for Visual Studio

Pass IronOCR single or multi page scanned images to receive all text, barcode, & QR content in return. The OCR library provides a set of classes to add OCR functionality into Web, Desktop or Console .Net Applications. Input formats can include PDF, JPG, PNG, GIF, BMP and TIFF.

The OCR (Optical Character Recognition) engine views pages formatted with multiple popular fonts, weights, italics, and underlines for accurate text reading. Cropping classes further assists OCR to perform at speed and with pinpoint accuracy. Iron’s multithreaded engine accelerates OCR speeds for multi-page documents on multi-core servers.

High Accuracy at High Speed

The OCR (Optical Character Recognition) engine views pages formatted with multiple popular fonts, weights, italics, and underlines for accurate text reading. Cropping classes further assists OCR to perform at speed and with pinpoint accuracy. Iron’s multithreaded engine accelerates OCR speeds for multi-page documents on multi-core servers.

Human Support Directly From Our Development Team

Whether its product, integration or licensing queries, the Iron product development team are on hand to support all of your questions. Get in touch and start a dialog with Iron to make the most of our library in your project.

Because the IronOCR API is well documented and easy learn, most C# coders are up and running in 60 seconds using the Nuget installer for Visual Studio.     Install Now »


C# OCR Results

Advanced Image Pre-processing for Consistent Results Every time

What really makes IronOCR special is its ability to read badly scanned documents. Its unique pre-processing library reduces background noise, rotation, distortion and skewed alignment as well as simplifying colors and enhancing resolution & contrast. Iron’s AutoOCR and Advanced OCR settings provide developers with the tools to achieve the best possible results, every time..


C# OCR Image to Text

Supports for Languages from across the world

IIronOCR covers languages from across the globe. Language packs available for: Arabic, Simplified Chinese, Traditional Chinese, Danish, English, Finnish, French, German, Hebrew, Italian, Japanese, Korean, Portuguese, Russian, Spanish, and Swedish. Other languages can be supported by request.


C# OCR Bitmap to Text

Output content into your project as Structured Data

IronOCR outputs content as plain text and barcode data. An alternative structured data object model allows developers to receive all content in the format of structured Headings, Paragraphs, Lines, Words and Characters for input directly into .Net applications.

Start reading text from images in 60 seconds

How To Install the IronOCR C# OCR Library into Visual Studio

Install IronOCR to your .Net Project

The easiest way to install IronOCR is using NuGet Package Manager for Visual-Studio:

  1. The package name is "IronOCR"
  2. If NuGet is unfamiliar to you… read this tutorial
  3. If you would prefer to download IronOCR as a dll and install manually.

C# OCR Example Code Demo

Get Coding

IronOCR has a very simple API based on HTML as a design language:

using IronOcr;
//..
var Ocr = new AutoOcr();
var Result = Ocr.Read(@"C:\path\to\image.png");
Console.WriteLine(Result.Text);
                                    
Imports IronOcr
Dim Ocr = New AutoOcr()
Dim Result = Ocr.Read("C:\path\to\image.png")
Console.WriteLine(Result.Text)
using IronOcr;
//..
var Ocr = new AdvancedOcr()
{
    CleanBackgroundNoise = true,
    EnhanceContrast = true,
    EnhanceResolution = true,
    Language =  IronOcr.Languages.English.OcrLanguagePack,
    Strategy = IronOcr.AdvancedOcr.OcrStrategy.Advanced,
    ColorSpace = AdvancedOcr.OcrColorSpace.Color,
    DetectWhiteTextOnDarkBackgrounds = true,
    InputImageType = AdvancedOcr.InputTypes.AutoDetect,
    RotateAndStraighten = true,
    ReadBarCodes = true,
    ColorDepth =4
};

var testImage = @"C:\path\to\scan.tiff";

var Results = Ocr.Read(testImage);

var Barcodes = Results.Barcodes.Select(b => b.Value);

Console.WriteLine(Results.Text);
Console.WriteLine("Barcodes:" + String.Join(",", Barcodes));
Imports IronOcr
Dim Ocr = New AdvancedOcr() With { _
     .CleanBackgroundNoise = True, _
     .EnhanceContrast = True, _
     .EnhanceResolution = True, _
     .Language = IronOcr.Languages.English.OcrLanguagePack, _
     .Strategy = IronOcr.AdvancedOcr.OcrStrategy.Advanced, _
     .ColorSpace = AdvancedOcr.OcrColorSpace.Color, _
     .DetectWhiteTextOnDarkBackgrounds = True, _
     .InputImageType = AdvancedOcr.InputTypes.AutoDetect, _
     .RotateAndStraighten = True, _
     .ReadBarCodes = True, _
     .ColorDepth = 4 _
}

Dim testImage = "C:\path\to\scan.tiff"

Dim Results = Ocr.Read(testImage)



Console.WriteLine(Results.Text)
 
var Ocr = new IronOcr.AutoOcr();
var Results = Ocr.ReadPdf(@"C:\Users\Me\Desktop\Invoice.pdf");


var Barcodes = Results.Barcodes;
var Text = Results.Text;
Console.WriteLine(Text);

Dim Ocr = New IronOcr.AutoOcr()
Dim Results = Ocr.ReadPdf("C:\Users\Me\Desktop\Invoice.pdf")
 
using IronOcr;

var Ocr = new AdvancedOcr()
{
    CleanBackgroundNoise = false,
    ColorDepth = 4,
    ColorSpace = AdvancedOcr.OcrColorSpace.Color,
    EnhanceContrast = false,
    DetectWhiteTextOnDarkBackgrounds = false,
    RotateAndStraighten = false,
    Language = IronOcr.Languages.English.OcrLanguagePack,
    EnhanceResolution = false,
    InputImageType = AdvancedOcr.InputTypes.Document,
    ReadBarCodes = true,
    Strategy = AdvancedOcr.OcrStrategy.Fast
};

var Results = Ocr.ReadPdf(@"C:\Users\Me\Desktop\Invoice.pdf");
var Pages = Results.Pages;
var Barcodes = Results.Barcodes;
var FullPdfText = Results.Text;

Imports IronOcr


Dim Ocr = New AdvancedOcr() With { _
  .CleanBackgroundNoise = False, _
  .ColorDepth = 4, _
  .ColorSpace = AdvancedOcr.OcrColorSpace.Color, _
  .EnhanceContrast = False, _
  .DetectWhiteTextOnDarkBackgrounds = False, _
  .RotateAndStraighten = False, _
  .Language = IronOcr.Languages.English.OcrLanguagePack, _
  .EnhanceResolution = False, _
  .InputImageType = AdvancedOcr.InputTypes.Document, _
  .ReadBarCodes = True, _
  .Strategy = AdvancedOcr.OcrStrategy.Fast _
}

Dim Results = Ocr.ReadPdf("C:\Users\Me\Desktop\Invoice.pdf")
Dim Pages = Results.Pages
Dim Barcodes = Results.Barcodes
Dim FullPdfText = Results.Text

 
using IronOcr;
using System;

// 19 Languages are currently supported by IronOCR
// To use them, please install the language packs (below) as required
var Ocr = new AdvancedOcr()
{
    Language = IronOcr.Languages.Arabic.OcrLanguagePack,
    ColorSpace = AdvancedOcr.OcrColorSpace.GrayScale,
    EnhanceResolution = true,
    EnhanceContrast = true,
    CleanBackgroundNoise = true,
    ColorDepth = 4,
    RotateAndStraighten = false,
    DetectWhiteTextOnDarkBackgrounds = false,
    ReadBarCodes = false,
    Strategy = AdvancedOcr.OcrStrategy.Fast,
    InputImageType = AdvancedOcr.InputTypes.Document
};

var results = Ocr.Read(@"path\to\arabic\document.png");

Console.WriteLine(results.Text);

Imports IronOcr

' 19 Languages are currently supported by IronOCR
' To use them, please install the language packs (below) as required

Dim Ocr = New AdvancedOcr() With {.Language = IronOcr.Languages.Arabic.OcrLanguagePack, .ColorSpace = AdvancedOcr.OcrColorSpace.GrayScale, .EnhanceResolution = True, .EnhanceContrast = True, .CleanBackgroundNoise = True, .ColorDepth = 4, .RotateAndStraighten = False, .DetectWhiteTextOnDarkBackgrounds = False, .ReadBarCodes = False, .Strategy = AdvancedOcr.OcrStrategy.Fast, .InputImageType = AdvancedOcr.InputTypes.Document}


Dim results = Ocr.Read("path\to\arabic\document.png")
Console.WriteLine(results.Text)

 
using IronOcr;
using System;
using System.Collections.Generic;
using System.Drawing; //Add Assembly Reference

// We can delve deep into OCR results as an object model of
// Pages, Barcodes, Paragraphs, Lines, Words and Characters
var Ocr = new AdvancedOcr()
{
    Language = IronOcr.Languages.English.OcrLanguagePack,
    ColorSpace = AdvancedOcr.OcrColorSpace.GrayScale,
    EnhanceResolution = true,
    EnhanceContrast = true,
    CleanBackgroundNoise = true,
    ColorDepth = 4,
    RotateAndStraighten = false,
    DetectWhiteTextOnDarkBackgrounds = false,
    ReadBarCodes = true,
    Strategy = AdvancedOcr.OcrStrategy.Fast,
    InputImageType = AdvancedOcr.InputTypes.Document
};

var results = Ocr.Read(@"path\to\document.png");

foreach (var page in results.Pages)
{
    // page object
    int page_number = page.PageNumber;
    String page_text = page.Text;
    int page_wordcount = page.WordCount;
    List barcodes = page.Barcodes;

    System.Drawing.Image page_image = page.Image;

    int page_width_px = page.Width;
    int page_height_px = page.Height;

    foreach (var paragraph in page.Paragraphs)
    {
        // pages -> paragraphs

        int paragraph_number = paragraph.ParagraphNumber;
        String paragraph_text = paragraph.Text;
        System.Drawing.Image paragraph_image = paragraph.Image;
        int paragraph_x_location = paragraph.X;
        int paragraph_y_location = paragraph.Y;
        int paragraph_width = paragraph.Width;
        int paragraph_height = paragraph.Height;
        double paragraph_ocr_accuracy = paragraph.Confidence;
        string paragraph_font_name = paragraph.FontName;
        double paragraph_font_size = paragraph.FontSize;
        OcrResult.TextFlow paragrapth_text_direction = paragraph.TextDirection;
        double paragrapth_rotation_degrees = paragraph.TextOrientation;

        foreach (var line in paragraph.Lines)
        {
            // pages -> paragraphs -> lines
            int line_number = line.LineNumber;
            String line_text = line.Text;
            System.Drawing.Image line_image = line.Image;
            int line_x_location = line.X;
            int line_y_location = line.Y;
            int line_width = line.Width;
            int line_height = line.Height;
            double line_ocr_accuracy = line.Confidence;
            double line_skew = line.BaselineAngle;
            double line_offset = line.BaselineOffset;

            foreach (var word in line.Words)
            {
                // pages -> paragraphs -> lines -> words
                int word_number = word.WordNumber;
                String word_text = word.Text;
                System.Drawing.Image word_image = word.Image;
                int word_x_location = word.X;
                int word_y_location = word.Y;
                int word_width = word.Width;
                int word_height = word.Height;
                double word_ocr_accuracy = word.Confidence;
                String word_font_name = word.FontName;
                double word_font_size = word.FontSize;
                bool word_is_bold = word.FontIsBold;
                bool word_is_fixed_width_font = word.FontIsFixedWidth;
                bool word_is_italic = word.FontIsItalic;
                bool word_is_serif_font = word.FontIsSerif;
                bool word_is_underlined = word.FontIsUnderlined;

                foreach (var character in word.Characters)
                {
                    // pages -> paragraphs -> lines -> words -> characters
                    int character_number = character.CharacterNumber;
                    String character_text = character.Text;
                    System.Drawing.Image character_image = character.Image;
                    int character_x_location = character.X;
                    int character_y_location = character.Y;
                    int character_width = character.Width;
                    int character_height = character.Height;
                    double character_ocr_accuracy = character.Confidence;
                }
            }
        }
    }
}


Imports IronOcr;
Imports System;
Imports System.Collections.Generic;
Imports System.Drawing 'Add Assembly Reference'

Dim Ocr = New AdvancedOcr() With {.Language = IronOcr.Languages.English.OcrLanguagePack, .ColorSpace = AdvancedOcr.OcrColorSpace.GrayScale, .EnhanceResolution = True, .EnhanceContrast = True, .CleanBackgroundNoise = True, .ColorDepth = 4, .RotateAndStraighten = False, .DetectWhiteTextOnDarkBackgrounds = False, .ReadBarCodes = True, .Strategy = AdvancedOcr.OcrStrategy.Fast, .InputImageType = AdvancedOcr.InputTypes.Document}

 Dim results = Ocr.Read("path\to\document.png")


    For Each page In results.Pages
        'page object'
        Dim page_number As Integer = page.PageNumber
        Dim page_text As String = page.Text
        Dim page_wordcount As Integer = page.WordCount
        Dim barcodes As List(Of OcrResult.OcrBarcode) = page.Barcodes
        Dim page_image As System.Drawing.Image = page.Image
        Dim page_width_px As Integer = page.Width
        Dim page_height_px As Integer = page.Height


        For Each paragraph In page.Paragraphs
            'pages -> paragraphs'
            Dim paragraph_number As Integer = paragraph.ParagraphNumber
            Dim paragraph_text As String = paragraph.Text
            Dim paragraph_image As System.Drawing.Image = paragraph.Image
            Dim paragraph_x_location As Integer = paragraph.X
            Dim paragraph_y_location As Integer = paragraph.Y
            Dim paragraph_width As Integer = paragraph.Width
            Dim paragraph_height As Integer = paragraph.Height
            Dim paragraph_ocr_accuracy As Double = paragraph.Confidence
            Dim paragraph_font_name As String = paragraph.FontName
            Dim paragraph_font_size As Double = paragraph.FontSize
            Dim paragrapth_text_direction As OcrResult.TextFlow = paragraph.TextDirection
            Dim paragrapth_rotation_degrees As Double = paragraph.TextOrientation

            For Each line In paragraph.Lines
                'pages -> paragraphs -> lines of text'
                Dim line_number As Integer = line.LineNumber
                Dim line_text As String = line.Text
                Dim line_image As System.Drawing.Image = line.Image
                Dim line_x_location As Integer = line.X
                Dim line_y_location As Integer = line.Y
                Dim line_width As Integer = line.Width
                Dim line_height As Integer = line.Height
                Dim line_ocr_accuracy As Double = line.Confidence
                Dim line_skew As Double = line.BaselineAngle
                Dim line_offset As Double = line.BaselineOffset

                For Each word In line.Words
                    'pages -> paragraphs -> lines of text  -> words'
                    Dim word_number As Integer = word.WordNumber
                    Dim word_text As String = word.Text
                    Dim word_image As System.Drawing.Image = word.Image
                    Dim word_x_location As Integer = word.X
                    Dim word_y_location As Integer = word.Y
                    Dim word_width As Integer = word.Width
                    Dim word_height As Integer = word.Height
                    Dim word_ocr_accuracy As Double = word.Confidence
                    Dim word_font_name As String = word.FontName
                    Dim word_font_size As Double = word.FontSize
                    Dim word_is_bold As Boolean = word.FontIsBold
                    Dim word_is_fixed_width_font As Boolean = word.FontIsFixedWidth
                    Dim word_is_italic As Boolean = word.FontIsItalic
                    Dim word_is_serif_font As Boolean = word.FontIsSerif
                    Dim word_is_underlined As Boolean = word.FontIsUnderlined
                    

                    For Each character In word.Characters
                        'pages -> paragraphs -> lines of text  -> words -> charachters'

                        Dim character_number As Integer = character.CharacterNumber
                        Dim character_text As String = character.Text
                        Dim character_image As System.Drawing.Image = character.Image
                        Dim character_x_location As Integer = character.X
                        Dim character_y_location As Integer = character.Y
                        Dim character_width As Integer = character.Width
                        Dim character_height As Integer = character.Height
                        Dim character_ocr_accuracy As Double = character.Confidence
                    Next 'character
                Next 'word
            Next 'line
        Next 'paragraph
    Next 'page
End Sub



How To Install the IronOCR C# OCR Library into Visual Studio

Add Additional Language Packs

English is installed as standard.   Additional OCR Languages packs are available for download:

  • IronOcr.Languages.Arabic Language Pack : Dll | NuGet
  • IronOcr.Languages.ChineseSimplified Language Pack : Dll | NuGet
  • IronOcr.Languages.ChineseTraditional Language Pack : Dll | NuGet
  • IronOcr.Languages.Czech Language Pack : Dll | NuGet
  • IronOcr.Languages.Danish Language Pack : Dll | NuGet
  • IronOcr.Languages.Finnish Language Pack : Dll | NuGet
  • IronOcr.Languages.French Language Pack : Dll | NuGet
  • IronOcr.Languages.German Language Pack : Dll | NuGet
  • IronOcr.Languages.Greek Language Pack : Dll | NuGet
  • IronOcr.Languages.Hebrew Language Pack : Dll | NuGet
  • IronOcr.Languages.Hungarian Language Pack : Dll | NuGet
  • IronOcr.Languages.Italian Language Pack : Dll | NuGet
  • IronOcr.Languages.Japanese Language Pack : Dll | NuGet
  • IronOcr.Languages.Korean Language Pack : Dll | NuGet
  • IronOcr.Languages.Norwegian Language Pack : Dll | NuGet
  • IronOcr.Languages.Polish Language Pack : Dll | NuGet
  • IronOcr.Languages.Portuguese Language Pack : Dll | NuGet
  • IronOcr.Languages.Russian Language Pack : Dll | NuGet
  • IronOcr.Languages.Spanish Language Pack : Dll | NuGet
  • IronOcr.Languages.Swedish Language Pack : Dll | NuGet
  • IronOcr.Languages.Thai Language Pack : Dll | NuGet
  • IronOcr.Languages.Turkish Language Pack : Dll | NuGet

Reliable Ocr tools for C# developers

C# OCR Documentation

Well Documented

Clear online manuals in plain English.

C# & VB Docs
C# OCR Library Licensing

Flexibly Licensed

Free Development. Commercial from $399.

Explore Licenses
C# PDF Open-Source Examples

Human Support

Talk directly with our development team

Ask a Question
visual studio Install C# PDF Generator by IronPdf

1 Minute Setup

Use Nuget Package Manager to install in under 60 seconds.