Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Microsoft Office Document Imaging used for Optical Character Recognition (OCR) but it support English language.i want to support for Arabic language.in my code i wrote Arabic
instead of english.it raise the error "MODI.MiLANGUAGES does not contain definition for miLANG_AR".whatever may be how can support MODi for Arabic language.i also wrote AR also but raise the error.if u not possible to solve the problem otherwise how can u read the text from image for arabic.pls intimate another approach if u possible

My code:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;
using System.Drawing.Imaging;

namespace OCRSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CheckFileType(@"C:\OCR");
        }
        /// <summary>
        /// Check for Images
        /// read text from these images.
        /// save text from each image in text file automaticly.
        /// handle problems with images
        /// </summary>
        /// <param name="directoryPath">Set Directory Path to check for Images in it</param>
        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_ARABIC, 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); 
            } 
            } 
            } 
        } 
    }
}




please help me.
Posted
Updated 29-Aug-15 9:45am
v2
Comments
Krishna Veni 29-Aug-15 23:55pm    
pls reply about question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900