Question

I am using MODI in order to implement ocr in one of my apps and every time I feed a tiff it only ocrs the first page of the tiff for some reason. That's my code: public string OCR(string path) {

        try
        {
            var md = new MODI.Document();
            md.Create(path);
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
            var image = (MODI.Image)md.Images[0];
            return image.Layout.Text;
        }
        catch (Exception ee)
        {
            if (ee.Message.ToLower() == "ocr running error")
                return ee.Message + ". No text found";
            else
                return " OCR not available. You need to have office installed.";
        }

    }

I guess I need a loop somewhere but how exactly?

Thanks in advance

No correct solution

OTHER TIPS

Probably along the lines:

StringBuilder sb = new StringBuilder();

foreach (MODI.Image image in md.Images) {
    sb.Append(image.Layout.Text);
}

//or

//for (int i = 0; i < md.Images.Count; i++) {
//    sb.Append(md.Images[i].Layout.Text);
//}

return sb.ToString();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top