Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Convert .tif file to .txt file in Windows application(.Net(C#))
Posted
Comments
Sandeep Mewara 5-Apr-13 2:06am    
Tried anything so far?
Prasad Khandekar 5-Apr-13 2:46am    
Hello Dheerendra,

Why not use any OCR software?

Path.ChangeExtension can be used to change the extention of Path string

EX:
String filePath = "E:\\WindowsPractice\\Class1.tif";
Path.ChangeExtension(filePath, ".txt");


To change the extention of the file physically:

File.Move(filePath, Path.ChangeExtension(filePath, ".txt"));
 
Share this answer
 
Hello Dheerendra,

Here is a small snippet based on ASPOSE OCR SDK.
C#
//Create OcrEngine instance and assign image, language and image configuration
OcrEngine ocr = new OcrEngine();
ocr.Image = ImageStream.FromFile("YOUR IMAGE PATH");
ocr.Languages.AddLanguage(Language.Load("english"));
ocr.Config.NeedRotationCorrection = chkRotation.Checked;
ocr.Config.UseDefaultDictionaries = true;
//Set resource file name and extract OCR text
using (ocr.Resource = new FileStream(resourceFileName, FileMode.Open)) {
    if (ocr.Process()) {
        strText = ocr.Text.ToString();
    }
}


A more complete sample can be found on ASPOSE web site[^]. There is a freeware wrapper[^] available for Tesseract[^] OCR Library as well. Another alternative is to use MODI which is part of Microsoft Office.

Regards,
 
Share this answer
 
Comments
Dheerendra Dwivedi 8-Apr-13 8:08am    
But how to Add OcrEngin in my Application
Prasad Khandekar 8-Apr-13 8:42am    
First you need to purchase ASPOSE OCR SDK or dowload the trial version. The link is given in the solution. Next you have to add reference to the Aspose OCR assembly.

1. Right-click the project's References node and select Add Reference from the menu.
2. In the Add Reference dialog, select the .NET tab
3. If you used an MSI installer to install Aspose.OCR, Aspose.OCR is listed in the top pane. Select Aspose.OCR and then click Select
4. If you downloaded and unpacked the DLL only, locate the Aspose.OCR.dll file using the Browse button

The getting started guide for Aspose.OCR Sdk is available here (http://www.aspose.com/docs/display/ocrnet/Getting%20Started)

Regards,
Dheerendra Dwivedi 11-Apr-13 7:13am    
mdoc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, True, True)is giive me OCR Error
Prasad Khandekar 11-Apr-13 8:00am    
What's the error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900