110,534
社区成员
发帖
与我相关
我的任务
分享
// 微软组件
// Microsoft Office Document Imaging 12.0 Type Library
// 语言 如果图片中含有中日韩等语言,则选择中日韩语言
// 我有个 ComboBox 可以选择语言的,这是个全局变量
MODI.MiLANGUAGES langs = MODI.MiLANGUAGES.miLANG_ENGLISH;
// 下面的代码加在某个按钮事件中
MODI.Document doc = new MODI.Document();
MODI.Image image;
MODI.Layout layout;
try
{
doc.Create(fileName /* 图片路径 */);
doc.OCR(langs, true, true);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < doc.Images.Count; i++)
{
image = (MODI.Image)doc.Images[i];
layout = image.Layout;
sb.AppendLine(string.Format("{0}, {1}", i, layout.Text));
}
doc.Close(false);
MessageBox.Show(sb.ToString());
}
catch (System.Exception ep)
{
MessageBox.Show(ep.Message);
}
finally
{
layout = null;
image = null;
doc = null;
}