I Planned to use OCR in my project and searched more OCR methods and i didnt find anything correctly. And at last i heard about MODI
and i tried that . But It throwing Following error:
Retrieving the COM class factory for component with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} failed due to the following error: 80040154
I'm Using Microsoft Office 2013
and visual studio 2012
.
The code me using is follows:
private void button1_Click(object sender, EventArgs e)
{
CheckFileType(@"E:\\");
}
public void CheckFileType(string directoryPath)
{
IEnumerator files = Directory.GetFiles(directoryPath).GetEnumerator();
while (files.MoveNext())
{
//get file extension
string fileExtension = Path.GetExtension(Convert.ToString(files.Current));
//get file name without extenstion
string fileName=Convert.ToString(files.Current).Replace(fileExtension,string.Empty);
//Check for JPG File Format
if (fileExtension == ".jpg" || fileExtension == ".JPG") // or // ImageFormat.Jpeg.ToString()
{
try
{
//OCR Operations ...
MODI.Document md = new MODI.Document();
md.Create(Convert.ToString(files.Current));
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
MODI.Image image = (MODI.Image)md.Images[0];
//create text file with the same Image file name
FileStream createFile = new FileStream(fileName + ".txt",FileMode.CreateNew);
//save the image text in the text file
StreamWriter writeFile = new StreamWriter(createFile);
writeFile.Write(image.Layout.Text);
writeFile.Close();
}
catch (Exception)
{
MessageBox.Show("This Image hasn't a text or has a problem",
"OCR Notifications",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
Can anyone help me in this ? Is that problem based on Microsoft Office version or Do i Need to make any changes ? Is that any better OCR
dll
? thanks ..
Best Answer
The reason for the error is that Microsoft Office Document Imaging(MODI) has been discontinued with MS Office 2010. This is collaborated to OneNote in Office 2013.
Even I am still searching for the solutions or if there are any other tools to extract text from images programaticaly. If you know of any or have the solution, please share it.