c#调用office2003的文字识别功能
bool CallOcx(string fileName, out string con)
{
con = "";
try
{
MODI.Document doc = new MODI.Document();
doc.Create(fileName);
doc.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, false, false);
MODI.Images images = doc.Images;
for (int i = 0; i < images.Count; i++)
{
MODI.Image image = (MODI.Image)images[i];
MODI.Layout layout = image.Layout;
con += layout.Text + "\r\n";
}
doc.Close(false);
doc = null;
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
{
con = "";
try
{
MODI.Document doc = new MODI.Document();
doc.Create(fileName);
doc.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, false, false);
MODI.Images images = doc.Images;
for (int i = 0; i < images.Count; i++)
{
MODI.Image image = (MODI.Image)images[i];
MODI.Layout layout = image.Layout;
con += layout.Text + "\r\n";
}
doc.Close(false);
doc = null;
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
}