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.




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;





// 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.