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; namespace WindowsFormsApplication4 { public partial class Form1 : Form { string extractedText = string.Empty; string getFileName; public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { getFileName = openFileDialog1.FileName; Image targetImage = Image.FromFile(getFileName); targetImage = fitInPBox(targetImage); pBox.Image = targetImage; } } //This function fit the browsed image in picture box private Image fitInPBox(Image img) { Bitmap image = new Bitmap(img, new Size(pBox.Size.Width, pBox.Size.Height)); return (Image)image; } private void button1_Click(object sender, EventArgs e) { richTextBox1.Text = string.Empty; MODI.Document doc = new MODI.Document(); doc.Create(getFileName); doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true); MODI.Image img = (MODI.Image)doc.Images[0]; MODI.Layout layout = img.Layout; for (int i = 0; i < layout.Words.Count; i++) { MODI.Word word = (MODI.Word)layout.Words[i]; if (extractedText.Length > 0) { extractedText += " "; } extractedText += word.Text; richTextBox1.Text = extractedText; } } private void Form1_Load(object sender, EventArgs e) { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)