Pankaj Singh

Pankaj Singh

  • NA
  • 97
  • 0

Extract text from tif images in which text are in italic font

Feb 4 2012 9:18 AM
Hi,
I am using following code that is working for mostly images but i have some special kinds of images which have italic text and tiff extension. in that case code is not working.
Code::
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)
{

}
}
}



Special Image URL::
https://lh4.googleusercontent.com/-hf9OII8wwgQ/TyldMWQdNAI/AAAAAAAAANQ/VSPNyF1aN5s/s512/UDE0002652.jpg
 
Please help me..
Thanks in advance

Answers (1)