“OCR running error” when using MODI 2003 with C#

巧了我就是萌 提交于 2019-12-05 07:45:44

It appears that the MODI failures may be cumulative; however through varying investigation it looks as though it may be tied to the DPI. Modifying the PixelFormat, clearing the background, adjusting the raw image size, and adjusting the OCROrientImage and OCRStraightenImage flags had no effect.

What worked for me was modifying the DPI of the written Bitmap for both horizontal and vertical to 300. The default for a Bitmap is 96 and in working with a specific image that did work I noted the DPI was set at 300.

I had similar problems and the terribly unhelpful error message seems to be generated when MODI is unable to OCR the bitmap. The solution I came up with is:

1 - Create your bitmap in either of these two formats System.Drawing.Imaging.PixelFormat.Format24bppRgb or System.Drawing.Imaging.PixelFormat.Format16bppRgb555

2 - Clear the background of the bitmap to white and then copy your text "picture" to the middle of it and then do the MODI.Document.Create (......

Its not a problem on code. Just update office 2003 service pack 3. Here is the link https://www.microsoft.com/en-us/download/details.aspx?id=8

It will work fine....

Change your code to this:

doc1.OCR;

And let the engine decide its own language.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!