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

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

  • Home
  • Licensing
  • EULA
  • Support & Update Extensions
  • Get Started
  • Languages
  • Code Examples
  • Tutorials
  • FAQ
  • Troubleshooting
  • API Reference
  • Search
  • Free NuGet Download
IronOCR Library for C# IronOCR Library for C#
  • Home
  • Licensing
    • Licensing
    • EULA
    • Support & Update Extensions
  • Docs
    • Search
    • Get Started
    • Languages
    • Code Examples
    • Tutorials
    • FAQ
    • Troubleshooting
    • API Reference
    • Search
  • Search
  • Free NuGet Download Total downloads: 434,111
Message's icon

Tesseract .NET OCR

  • # Tesseract OCR implementation for .NET text recognition
  • # Results in structured data or text string
  • # Includes Tesseract OCR for C#
Free NuGet Download Total downloads: 434,111

Or download the DLL directly here

Trusted by:

Trusted by: NASA, Lego, Hertz, 3M

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;

var Result = new IronTesseract().Read(@"images\image.png").Text;
' Nuget PM> Install-Package IronOcr
Imports IronOcr

Private Result = (New IronTesseract()).Read("images\image.png").Text
Install-Package IronOcr
PDF OCR Text Extraction See All 24 Code Examples
using IronOcr;

var Ocr = new IronTesseract();


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

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

    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr

Private Ocr = New IronTesseract()


Using Input = New OcrInput()
	' OCR entire document
	Input.AddPdf("example.pdf", "password")

	' Alternatively OCR selected page numbers
	Input.AddPdfPages("example.pdf", { 1, 2, 3 }, "password")

	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
OCR with Barcode & QR Reading See All 24 Code Examples
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
using (var Input = new OcrInput(@"images\imageWithBarcode.png"))
{
    var Result = Ocr.Read(Input);
    foreach (var barcode in Result.Barcodes) {
        Console.WriteLine(barcode.Value);
    }
}
Dim Ocr = New IronTesseract()
Ocr.Configuration.ReadBarCodes = True
Using Input = New OcrInput("images\imageWithBarcode.png")
	Dim Result = Ocr.Read(Input)
	For Each barcode In Result.Barcodes
		Console.WriteLine(barcode.Value)
	Next barcode
End Using
Install-Package IronOcr
125 International OCR Languages See All 24 Code Examples
//PM> Install-Package IronOcr.Languages.Arabic

using IronOcr;

var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic;

using (var Input = new OcrInput(@"images\arabic.gif"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}


///A more advanced Example

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

using (var Input = new OcrInput(@"images\mixed-lang.pdf"))
{
    var Result = Ocr2.Read(Input);
    Console.WriteLine(Result.Text);
}
'PM> Install-Package IronOcr.Languages.Arabic

Imports IronOcr

Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Arabic

Using Input = New OcrInput("images\arabic.gif")
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using


'''A more advanced Example

Dim Ocr2 = New IronTesseract()
Ocr2.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata")
Ocr2.AddSecondaryLanguage(OcrLanguage.EnglishBest)

Using Input = New OcrInput("images\mixed-lang.pdf")
	Dim Result = Ocr2.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
Fixing Low Quality Scans & Images See All 24 Code Examples
using IronOcr;

var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"images\image.png"))
{
    Input.Deskew();
    // Input.DeNoise(); // only use if accuracy <97%
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr

Private Ocr = New IronTesseract()
Using Input = New OcrInput("images\image.png")
	Input.Deskew()
	' Input.DeNoise(); // only use if accuracy <97%
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
Fast OCR Configuration See All 24 Code Examples
var Ocr = new IronTesseract();

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

// Latest Engine 
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;

//AI OCR only without font analysis
Ocr.Configuration.EngineMode = TesseractEngineMode.LstmOnly; 

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

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

using (var Input = new OcrInput(@"images\image.png"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Dim Ocr = New IronTesseract()

' Fast Dictionary
Ocr.Language = OcrLanguage.EnglishFast

' Latest Engine 
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5

'AI OCR only without font analysis
Ocr.Configuration.EngineMode = TesseractEngineMode.LstmOnly

'Turn off unneeded options
Ocr.Configuration.ReadBarCodes = False
Ocr.Configuration.RenderSearchablePdfsAndHocr = False

' Assume text is laid out neatly in an orthagonal document
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto

Using Input = New OcrInput("images\image.png")
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
OCR Image Optimization Filters See All 24 Code Examples
using IronOcr;

var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"images\image.png"))
{
    Input.WithTitle("My Document");
    Input.Binarize();
    Input.Contrast();
    Input.Deskew();
    Input.DeNoise();
    Input.Dilate();
    Input.EnhanceResolution(300);
    Input.Invert();
    Input.Rotate(90);
    Input.Scale(150); // or Input.Scale(3000, 2000);
    Input.Sharpen();
    Input.ToGrayScale();

    // you don't need all of them
    // most users only need Deskew() and occasionally DeNoise() 

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

    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr

Private Ocr = New IronTesseract()
Using Input = New OcrInput("images\image.png")
	Input.WithTitle("My Document")
	Input.Binarize()
	Input.Contrast()
	Input.Deskew()
	Input.DeNoise()
	Input.Dilate()
	Input.EnhanceResolution(300)
	Input.Invert()
	Input.Rotate(90)
	Input.Scale(150) ' or Input.Scale(3000, 2000);
	Input.Sharpen()
	Input.ToGrayScale()

	' you don't need all of them
	' most users only need Deskew() and occasionally DeNoise() 


	' Optional: Export modified images so you can view them.
	For Each page In Input.Pages
		  page.SaveAsImage("filtered.bmp")
	Next page


	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
OcrResult Class See All 24 Code Examples
using IronOcr;
using System.Drawing; //for image export

// 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 Ocr = new IronTesseract();
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
Ocr.Configuration.ReadBarCodes = true;
using (var Input = new OcrInput(@"example.tiff"))
{
    OcrResult Result = Ocr.Read(Input);
    foreach (var Page in Result.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;
        System.Drawing.Bitmap PageImage = Page.ToBitmap(Input);
        int PageWidth = Page.Width;
        int PageHeight = Page.Height;
        int PagRotation = 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;
            System.Drawing.Bitmap ParagraphImage = Paragraph.ToBitmap(Input);
            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;
                System.Drawing.Bitmap LineImage = Line.ToBitmap(Input); ;
                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;
                    System.Drawing.Image WordImage = Word.ToBitmap(Input);
                    int WordX_location = Word.X;
                    int WordY_location = Word.Y;
                    int WordWidth = Word.Width;
                    int WordHeight = Word.Height;
                    double WordOcrAccuracy = Word.Confidence;
                    if (Word.Font != null)
                    {
                        // Word.Font is only set when using Tesseract Engine Modes rather than LTSM
                        String FontName = Word.Font.FontName;
                        double FontSize = Word.Font.FontSize;
                        bool IsBold = Word.Font.IsBold;
                        bool IsFixedWidth = Word.Font.IsFixedWidth;
                        bool IsItalic = Word.Font.IsItalic;
                        bool IsSerif = Word.Font.IsSerif;
                        bool IsUnderLined = Word.Font.IsUnderlined;
                        bool IsFancy = Word.Font.IsCaligraphic;
                    }
                    foreach (var Character in Word.Characters)
                    {
                        // Pages -> Paragraphs -> Lines -> Words -> Characters
                        int CharacterNumber = Character.CharacterNumber;
                        String CharacterText = Character.Text;
                        System.Drawing.Bitmap CharacterImage = Character.ToBitmap(Input);
                        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;
                    }
                }
            }
        }
    }
}
Imports IronOcr
Imports System.Drawing 'for image export

' 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/
Private Ocr = New IronTesseract()
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm
Ocr.Configuration.ReadBarCodes = True
Using Input = New OcrInput("example.tiff")
	Dim Result As OcrResult = Ocr.Read(Input)
	For Each Page In Result.Pages
		' Page object
		Dim PageNumber As Integer = Page.PageNumber
		Dim PageText As String = Page.Text
		Dim PageWordCount As Integer = Page.WordCount
		' null if we dont set Ocr.Configuration.ReadBarCodes = true;
		Dim Barcodes() As OcrResult.Barcode = Page.Barcodes
		Dim PageImage As System.Drawing.Bitmap = Page.ToBitmap(Input)
		Dim PageWidth As Integer = Page.Width
		Dim PageHeight As Integer = Page.Height
		Dim PagRotation As Integer = Page.Rotation ' angular correction in degrees from OcrInput.Deskew()

		For Each Paragraph In Page.Paragraphs
			' Pages -> Paragraphs
			Dim ParagraphNumber As Integer = Paragraph.ParagraphNumber
			Dim ParagraphText As String = Paragraph.Text
			Dim ParagraphImage As System.Drawing.Bitmap = Paragraph.ToBitmap(Input)
			Dim ParagraphX_location As Integer = Paragraph.X
			Dim ParagraphY_location As Integer = Paragraph.Y
			Dim ParagraphWidth As Integer = Paragraph.Width
			Dim ParagraphHeight As Integer = Paragraph.Height
			Dim ParagraphOcrAccuracy As Double = Paragraph.Confidence
			Dim paragrapthText_direction As OcrResult.TextFlow = Paragraph.TextDirection
			For Each Line In Paragraph.Lines
				' Pages -> Paragraphs -> Lines
				Dim LineNumber As Integer = Line.LineNumber
				Dim LineText As String = Line.Text
				Dim LineImage As System.Drawing.Bitmap = Line.ToBitmap(Input)

				Dim LineX_location As Integer = Line.X
				Dim LineY_location As Integer = Line.Y
				Dim LineWidth As Integer = Line.Width
				Dim LineHeight As Integer = Line.Height
				Dim LineOcrAccuracy As Double = Line.Confidence
				Dim LineSkew As Double = Line.BaselineAngle
				Dim LineOffset As Double = Line.BaselineOffset
				For Each Word In Line.Words
					' Pages -> Paragraphs -> Lines -> Words
					Dim WordNumber As Integer = Word.WordNumber
					Dim WordText As String = Word.Text
					Dim WordImage As System.Drawing.Image = Word.ToBitmap(Input)
					Dim WordX_location As Integer = Word.X
					Dim WordY_location As Integer = Word.Y
					Dim WordWidth As Integer = Word.Width
					Dim WordHeight As Integer = Word.Height
					Dim WordOcrAccuracy As Double = Word.Confidence
					If Word.Font IsNot Nothing Then
						' Word.Font is only set when using Tesseract Engine Modes rather than LTSM
						Dim FontName As String = Word.Font.FontName
						Dim FontSize As Double = Word.Font.FontSize
						Dim IsBold As Boolean = Word.Font.IsBold
						Dim IsFixedWidth As Boolean = Word.Font.IsFixedWidth
						Dim IsItalic As Boolean = Word.Font.IsItalic
						Dim IsSerif As Boolean = Word.Font.IsSerif
						Dim IsUnderLined As Boolean = Word.Font.IsUnderlined
						Dim IsFancy As Boolean = Word.Font.IsCaligraphic
					End If
					For Each Character In Word.Characters
						' Pages -> Paragraphs -> Lines -> Words -> Characters
						Dim CharacterNumber As Integer = Character.CharacterNumber
						Dim CharacterText As String = Character.Text
						Dim CharacterImage As System.Drawing.Bitmap = Character.ToBitmap(Input)
						Dim CharacterX_location As Integer = Character.X
						Dim CharacterY_location As Integer = Character.Y
						Dim CharacterWidth As Integer = Character.Width
						Dim CharacterHeight As Integer = Character.Height
						Dim CharacterOcrAccuracy As Double = Character.Confidence
						' Output alternative symbols choices and their probability.
						' Very useful for spellchecking
						Dim Choices() As OcrResult.Choice = Character.Choices
					Next Character
				Next Word
			Next Line
		Next Paragraph
	Next Page
End Using
Install-Package IronOcr
Create Searchable PDFs by OCR See All 24 Code Examples
using IronOcr;

  var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
    Input.Add(@"images\page1.png")
    Input.Add(@"images\page2.bmp")
    Input.Add(@"images\page3.tiff")

    Input.Deskew();

    var Result = Ocr.Read(Input);
    Result.SaveAsSearchablePdf("searchable.pdf");
}
Imports IronOcr

  Private Ocr = New IronTesseract()
Using Input = New OcrInput()
	Input.Add("images\page1.png") Input.Add("images\page2.bmp") Input.Add("images\page3.tiff") Input.Deskew()

	Dim Result = Ocr.Read(Input)
	Result.SaveAsSearchablePdf("searchable.pdf")
End Using
Install-Package IronOcr
Tesseract 5 for .NET See All 24 Code Examples
using IronOcr;
//..
var Ocr = new IronTesseract();
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
// This is default
using (var Input = new OcrInput(@"images\image.png"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr
'..
Private Ocr = New IronTesseract()
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
' This is default
Using Input = New OcrInput("images\image.png")
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
Install-Package IronOcr
Iron Ocr

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 $499.

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: 2022.3.0
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: 2022.3.0
Download Now
Manually install into your project
  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 $499

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 License
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 Licenses
Schedule a call
Licenses from $499. 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
  • FAQ
  • Credits
  • Blog
  • Product Brochure

Tutorials

  • Get Started
  • C# Image to Text
  • C# Tesseract OCR

Licensing

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

Try IronOCR Free

  • Download on NuGet
  • Download DLL
  • 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
  • Contact Us

Supporting Teamseas

Copyright © Iron Software LLC 2013-2022

  • Terms
  • Privacy

Thank you!

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

48-Hour Upgrade Offer:

Save 50% on a
Professional Upgrade

Go Professional to cover 10 developers
and unlimited projects.

Upgrade to Professional

Upgrade

Professional

$600 USD

$299 USD


  • 10 developers
  • 10 locations
  • 10 projects