OCR: How to C#
Using OCR SDK for C#.NET
Sample C#.NET Codes
Quick to Start
  |  
Home ›› XImage.OCR ›› C# OCR: Quick to Start

C#: Quick to Start with Tiff Image Text Extraction


Help C# User Have Quick Evaluation of .NET OCR SDK, Providing Simple Sample Code to Extract Text from a Tiff File




On this tutorial, we provide free Visual C# programming code for testing the functionality of text extraction from raster image Tiff. You may directly copy demo code below to your C#.NET project to have a quick evaluation of our XImage.OCR for .NET. At the very beginning, you may install .NET OCR SDK DLLs into your Visual Studio C# project as references. Please note that, for Tiff image text extraction, RasterEdge.Imaging.TIFF.dll should also be added as project reference.


Related .net document control helps:
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net document viewer control: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net pdf viewer control free: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net dicom library: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net mvc image viewer: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
asp.net sharepoint document viewer control: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint




C# Sample Code to Extract Text from Tiff Image File



By using well developed .NET APIs, C# programmers are able to extract and recognize Tiff image file characters. Both single page Tiff image and multi-page Tiff image are supported by our OCR Toolkit for C#.NET. And the following free code example is available for these two forms. As you see, you can choose to load a certain page of Tiff image file and get its text. After recognition, OCR result can be saved and output as text, PDF and SVG files.


Add References


  RasterEdge.XImage.OCR.dll


  RasterEdge.XImage.OCR.Tesseract.dll


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.AdvancedCleanup.Core.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XDoc.TIFF.dll


Using Namespaces


  using RasterEdge.XDoc.TIFF;


  using RasterEdge.XImage.OCR;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.





// Set the training data path. Please put eng.traineddata (for English) under the path specified.
OCRHandler.SetTrainResourcePath(@"c:\source");

// Set supported language. You can also set this attribute in OCRPage or OCRZone.
OCRHandler.Settings.LanguagesEnabled.Add(Language.Fra);

// Load Tiff image file.
TIFFDocument doc = new TIFFDocument(@"c:\sample.tif");

// Load the first page to recongnize.
TIFFPage page = (TIFFPage)doc.GetPage(0);

// Rasterize the page with a resolution multipi.
Bitmap bmp =  page.GetBitmap(1.5f);

// Import the page to recoginze.
OCRPage oPage = OCRHandler.Import(bmp);
oPage.Recognize();

// Save OCR result as a supportive documet format (Txt, PDF and SVG).
oPage.SaveTo(MIMEType.TXT,@"c:\sample.txt");

// Or you can output the text directly.
Console.WriteLine(oPage.GetText());





More C# Demos for Using OCR Software



If you need to use OCR technology to recognize and extract text content from other supportive image and document formats, please directly refer to More C# Demos for Image File Text Extraction.