Microsoft Office Document Imaging (MODI) OCR
regsvr32.exe mdivwctl.dll,
MDIVWCTL.DLL is part of MS office 2003.
OCR MODI Library (MDIVWCTL.DLL) is freely available
regsvr32.exe "C:\Program Files\Common Files\Microsoft Shared\MODI\11.0\mdivwctl.dll"
OFFICE2007 Files\Common Files\Microsoft Shared\MODI\12.0 MDIVWCTL.dll
C:\Program Files\Common Files\Microsoft Shared\MODI\11.0, 21MB
Install MODI for use with Microsoft Office
https://support.microsoft.com/en-us/topic/install-modi-for-use-with-microsoft-office-2010-4fbd3076-6d01-9cb7-c574-3bbabc9eead9
Microsoft Office Document Imaging 11.0 Type Library
CreateObject("MODI.Document")
miDoc.Images(0).OCR miLANG_CHINESE_SIMPLIFIED, True, True '
strLayoutInfo = _
"Language: " & modiLayout.Language & vbCrLf & _
"Number of characters: " & modiLayout.NumChars & vbCrLf & _
"Number of fonts: " & modiLayout.NumFonts & vbCrLf & _
"Number of words: " & modiLayout.NumWords & vbCrLf & _
"Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _
"First word of text: " & modiLayout.Words(0).Text
MsgBox strLayoutInfo, vbInformation + vbOKOnly, "Layout Information"
Set modiLayout = Nothing
Set miDoc = Nothing
uses ...
ComObj, MODI_TLB
doc := CreateOleObject('MODI.Document') as IDocument;
CoCreateInstance(CLASS_Document,
NIL,
CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,
IDocument,
doc);
Var
doc :IDocument;
Img :IImage;
Layout :ILayout;
begin
doc := IDispatch(CreateOleObject('MODI.Document')) as IDocument;
doc.create(FileName); // just put here the filename of an image
doc.OCR(miLANG_ENGLISH,true,true);
Img := IDispatch(doc.Images[0]) as IImage;
Layout := IDispatch(Img.Layout) as ILayout;
Memo1.Lines.Add(Layout.Text);
MiDocView1.Document := doc;
doc.Close(false);
Img := nil;
Layout := nil;
Screen.MousePointer = vbDefault
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa202819(v=office.11)
try
if CoCreateInstance(CLASS_Document,
NIL,
CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,
IDocument,
fMODIdoc)<>S_OK then
begin
Application.MessageBox(sNoMODIDocIntf,sMODI,MB_OK+MB_ICONSTOP);
Exit;
end;
fMODIdoc.Create(WideString(ImgName));
try
if ( xxxxx ) then LangID:=miLANG_HUNGARIAN else LangID:=miLANG_ENGLISH;
(fMODIdoc.Images[0] as IImage).OCR(LangID,FALSE,FALSE);
for i:=0 to (fMODIdoc.Images[0] as IImage).Layout.Words.Count-1 do
begin
aWord:=(fMODIdoc.Images[0] as IImage).Layout.Words[i] as IWord;
nRects:=aWord.Rects;
for j:=0 to nRects.Count-1 do
begin
aRect:=nRects.Item[j] as IMiRect;
if (p.X>=aRect.Left) and
(p.X<=aRect.Right) and
(p.Y>=aRect.Top) and
(p.Y<=aRect.Bottom) then
begin
Result:=aWord.Text;
Exit;
end;
end;
end;
finally
fMODIdoc.Close(FALSE);
end;
except
end;
var
modi: olevariant;
fname: TFileName; //MDIVWCTL.DLL http://www.microsoft.com/ru-ru/download/confirmation.aspx?id=21581
i: integer;
s: string;
begin
fname:= '1.tif';
modi:= CreateOLEObject('MODI.Document');
modi.Create(fname);
modi.OCR();
s:= '';
for i:= 0 To modi.Images.Count - 1 do
s:= s+ modi.Images(i).Layout.Text;
showmessage(s);
//showmessage(modi.images.item(0).layout.text);
modi.close;
modi:= UnAssigned;
end;
https://social.msdn.microsoft.com/Forums/en-US/29093b50-1f09-4b5e-9f41-c0f4a540852f/using-modi-microsoft-office-document-imaging-how-to-get-images-and-table-in-text-file?forum=worddev
using MODI (Microsoft Office Document Imaging) how to get images and table in text file
MODI and OpenXML SDK
http://www.codeproject.com/KB/office/OCRSampleApplication.aspx
&
This sample project demonstrates how to export, delete and replace the images in a document by using Open XML SDK
http://code.msdn.microsoft.com/CSManipulateImagesInWordDoc-312da7ef
I hope this helps.
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa167607(v=office.11)?redirectedfrom=MSDN
Using the Microsoft Office Document Imaging 2003 Object Model
// CCMD_OCRView.cpp : implementation of the CCCMD_OCRView class |
// CCMD_OCRView.cpp : implementation of the CCCMD_OCRView class
//
#include "stdafx.h"
#include "CCMD_OCR.h"
#include "CCMD_OCRDoc.h"
#include "CCMD_OCRView.h"
#include "../class/global.h"//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "mdivwctl.h"
enum MiLANGUAGES
{ miLANG_CHINESE_SIMPLIFIED = 2052,
miLANG_CHINESE_TRADITIONAL = 1028,
miLANG_CZECH = 5,
miLANG_DANISH = 6,
miLANG_DUTCH = 19,
miLANG_ENGLISH = 9,
miLANG_FINNISH = 11,
miLANG_FRENCH = 12,
miLANG_GERMAN = 7,
miLANG_GREEK = 8,
miLANG_HUNGARIAN = 14,
miLANG_ITALIAN = 16,
miLANG_JAPANESE = 17,
miLANG_KOREAN = 18,
miLANG_NORWEGIAN = 20,
miLANG_POLISH = 21,
miLANG_PORTUGUESE = 22,
miLANG_RUSSIAN = 25,
miLANG_SPANISH = 10,
miLANG_SWEDISH = 29,
miLANG_SYSDEFAULT = 2048,
miLANG_TURKISH = 31
};
enum MiFILE_FORMAT
{ miFILE_FORMAT_DEFAULTVALUE = -1,
miFILE_FORMAT_TIFF = 1,
miFILE_FORMAT_TIFF_LOSSLESS = 2,
miFILE_FORMAT_MDI = 4
};
enum MiCOMP_LEVEL
{ miCOMP_LEVEL_LOW = 0,
miCOMP_LEVEL_MEDIUM = 1,
miCOMP_LEVEL_HIGH = 2
};
/////////////////////////////////////////////////////////////////////////////
// CCCMD_OCRView
IMPLEMENT_DYNCREATE(CCCMD_OCRView, CFormView)
BEGIN_MESSAGE_MAP(CCCMD_OCRView, CFormView)
//{{AFX_MSG_MAP(CCCMD_OCRView)
ON_WM_PAINT()
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()