Call the Microsoft Office Document Imaging class library
The source code is as follows:
Public MODI. Document _ MODIDocument;
Private void SetImage (string filename)
{
// Bitmap nump = new Bitmap ();
// Bitmap myBitmap1 = new Bitmap (new fa;
// Set the image ..
Try
{
_ MODIDocument = new MODI. Document ();
_ MODIDocument. Create (filename );
// AxMiDocView1.Document = _ MODIDocument;
// AxMiDocView1.Refresh ();
}
Catch (System. Runtime. InteropServices. COMException ee)
{
MessageBox. Show (ee. Message );
}
}
Public string Analyse ()
{
String texts = "";
If (_ MODIDocument = null) return texts;
Try
{
// Add event handler for progress visualisation
// _ MODIDocument. OnOCRProgress + = new MODI. _ imo-entevents_onocrprogresseventhandler (this. ShowProgress );
// The MODI call for OCR
// _ MODIDocument. OCR (_ MODIParameters. Language, _ MODIParameters. WithAutoRotation, _ MODIParameters. WithStraightenImage );
_ MODIDocument. OCR (MODI. MiLANGUAGES. miLANG_CHINESE_SIMPLIFIED, true, true );
// This. textBox1.Text = (_ MODIDocument. Images [0] as MODI. Image). Layout. Text;
// MessageBox. Show (_ MODIDocument. Images [0] as MODI. Image). Layout. Text );
Texts = (_ MODIDocument. Images [0] as MODI. Image). Layout. Text;
// StatusBar1.Text = "Ready .";
_ MODIDocument. Close (false );
_ MODIDocument = null;
}
Catch (Exception ee)
{
// Simple exception "handling"
MessageBox. Show (ee. Message );
}
Return texts;
}