I m also try this way - How to generate and image form given text or how to convert text in to image? Dotnet framework provides System.Drawing and System.Drawing.Graphics class which helps us to generate image from text or convert text into image. Below is the code,
private Bitmap CreateBitmapImage(string sImageText)
2: {
3: Bitmap objBmpImage = new Bitmap(1, 1);
4:
5: int intWidth = 0;
6: int intHeight = 0;
7:
8: // Create the Font object for the image text drawing.
9: Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
10:
11: // Create a graphics object to measure the text's width and height.
12: Graphics objGraphics = Graphics.FromImage(objBmpImage);
13:
14: // This is where the bitmap size is determined.
15: intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width;
16: intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height;
17:
18: // Create the bmpImage again with the correct size for the text and font.
19: objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
20:
21: // Add the colors to the new bitmap.
22: objGraphics = Graphics.FromImage(objBmpImage);
23:
24: // Set Background color
25: objGraphics.Clear(Color.White);
26: objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
27: objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
28: objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
29: objGraphics.Flush();
30:
31: return (objBmpImage);
32: }
the technique that is used to convert the drawn text on images to real text is known as OCR(optical character recognition). now to do OCR your image should be clean, meaning it should be scanned straight and it should have a good contrast. the contrast can
be manipulated by using System.Drawing namespace but scanning the document in a correct way is not something you can control.
to generate the word document you can use another third party library:
True. It's not that easy to use OCR open source. What kind of error messages did you get when doing the OCR?
Also, have you ever considered using a third-party OCR sdk, self-designed or packaged based on the open source? Any of the options will make the coding much eaiser.
This
OCR SDK is based on the Tesseract OCR engine. You can check it out if you are interested in.
supriya1
0 Points
7 Posts
conversion from scanned image to any text
Mar 30, 2012 06:25 AM|LINK
How to convert scanned image to any word doc or aiken format in c#
MP Gopi
Member
14 Points
32 Posts
Re: conversion from scanned image to any text
Mar 30, 2012 06:38 AM|LINK
private Bitmap CreateBitmapImage(string sImageText) 2: { 3: Bitmap objBmpImage = new Bitmap(1, 1); 4: 5: int intWidth = 0; 6: int intHeight = 0; 7: 8: // Create the Font object for the image text drawing. 9: Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); 10: 11: // Create a graphics object to measure the text's width and height. 12: Graphics objGraphics = Graphics.FromImage(objBmpImage); 13: 14: // This is where the bitmap size is determined. 15: intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width; 16: intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height; 17: 18: // Create the bmpImage again with the correct size for the text and font. 19: objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight)); 20: 21: // Add the colors to the new bitmap. 22: objGraphics = Graphics.FromImage(objBmpImage); 23: 24: // Set Background color 25: objGraphics.Clear(Color.White); 26: objGraphics.SmoothingMode = SmoothingMode.AntiAlias; 27: objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias; 28: objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0); 29: objGraphics.Flush(); 30: 31: return (objBmpImage); 32: }hj
Contributor
2536 Points
552 Posts
Re: conversion from scanned image to any text
Mar 30, 2012 06:55 AM|LINK
well that's a lot of trouble without using third party library. so here is the library that might help you out:
http://www.ocrtools.com/fi/Download.aspx
the technique that is used to convert the drawn text on images to real text is known as OCR(optical character recognition). now to do OCR your image should be clean, meaning it should be scanned straight and it should have a good contrast. the contrast can be manipulated by using System.Drawing namespace but scanning the document in a correct way is not something you can control.
to generate the word document you can use another third party library:
http://worddocgenerator.codeplex.com/
supriya1
0 Points
7 Posts
Re: conversion from scanned image to any text
Apr 02, 2012 08:34 AM|LINK
Its not working. I wanna convert scanned image(which contains text) to word document.
SonicMan
Participant
1472 Points
228 Posts
Re: conversion from scanned image to any text
Apr 02, 2012 08:57 AM|LINK
HI
Have you try the Hj's suggestion?
I think it's hard and it's not asp.net tech.
You should learn some OCR tech.
supriya1
0 Points
7 Posts
Re: conversion from scanned image to any text
Apr 03, 2012 08:01 AM|LINK
yeah but using OCR open source is also not so easy.I used in my code but its not working.
Getting an error like Application class is having no any constructors and im unable to solve it i.
catherine se...
Participant
756 Points
190 Posts
Re: conversion from scanned image to any text
Aug 20, 2012 05:57 AM|LINK
True. It's not that easy to use OCR open source. What kind of error messages did you get when doing the OCR?
Also, have you ever considered using a third-party OCR sdk, self-designed or packaged based on the open source? Any of the options will make the coding much eaiser.
This OCR SDK is based on the Tesseract OCR engine. You can check it out if you are interested in.
Love Version Control and .NET Scanner SDK