1、 int miLANG_CHINESE_SIMPLIFIED = 2052 ;IDocument * pDoc = new IDocument;pDoc - CreateDispatch( _T( “ MODI.Document “ ) );pDoc - Create(GetAppPath() + _T( “ out.bmp “ );pDoc - OCR( miLANG_CHINESE_SIMPLIFIED, 0 , 0 );IImages images = pDoc - GetImages();long num = images.GetCount();for ( int i = 0 ; i
2、Close( 0 );pDoc - ReleaseDispatch();delete pDoc; 还需要导入 Office2003 的 Dispatch 接口包装类1 / Machine generated IDispatch wrapper class(es) created with ClassWizard 2 / /3 / IMiFont wrapper class 4 5 class IMiFont : public COleDispatchDriver6 7 public :8 IMiFont() / Calls COleDispatchDriver default construc
3、tor 9 IMiFont(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 10 IMiFont( const IMiFont 18 long GetFaceStyle();19 long GetSerifStyle();20 short GetFontSize();21 ;22 / /23 / IMiRect wrapper class 24 25 class IMiRect : public COleDispatchDriver26 27 public :28 IMiRect() / Calls COleDispatchDrive
4、r default constructor 29 IMiRect(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 30 IMiRect( const IMiRect 38 long GetLeft();39 long GetRight();40 long GetBottom();41 ;42 / /43 / IMiRects wrapper class 44 45 class IMiRects : public COleDispatchDriver46 47 public :48 IMiRects() / Calls COleDisp
5、atchDriver default constructor 49 IMiRects(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 50 IMiRects( const IMiRects 58 LPUNKNOWN Get_NewEnum();59 LPDISPATCH GetItem( long Index);60 ;61 / /62 / IWord wrapper class 63 64 class IWord : public COleDispatchDriver65 66 public :67 IWord() / Calls
6、COleDispatchDriver default constructor 68 IWord(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 69 IWord( const IWord 77 long GetFontId();78 long GetLineId();79 long GetRegionId();80 CString GetText();81 LPDISPATCH GetFont();82 long GetId();83 LPDISPATCH GetRects();84 ;85 / /86 / IWords wrappe
7、r class 87 88 class IWords : public COleDispatchDriver89 90 public :91 IWords() / Calls COleDispatchDriver default constructor 92 IWords(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 93 IWords( const IWords 101 LPUNKNOWN Get_NewEnum();102 LPDISPATCH GetItem( long Index);103 ;104 / /105 / ILa
8、yout wrapper class 106 107 class ILayout : public COleDispatchDriver108 109 public :110 ILayout() / Calls COleDispatchDriver default constructor 111 ILayout(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 112 ILayout( const ILayout / 获得 OCR 处理时的使用的语言设置 120 long GetNumChars(); / 获得已经辨认文本的字符数目 1
9、21 long GetNumWords();122 long GetNumFonts(); / 获得字体 123 CString GetText(); / 以单 CString 方式获得辨认文本 124 LPDISPATCH GetWords();125 ;126 / /127 / IImage wrapper class 128 129 class IImage : public COleDispatchDriver130 131 public :132 IImage() / Calls COleDispatchDriver default constructor 133 IImage(LP
10、DISPATCH pDispatch) : COleDispatchDriver(pDispatch) 134 IImage( const IImage / 获得 OCR 页面结果 142 long GetPixelWidth(); / 获取像素的宽 143 long GetPixelHeight(); / 获取像素的高 144 long GetXdpi(); / 获取每英寸 X 轴像素 145 long GetYdpi(); / 获取每英寸 Y 轴像素 146 long GetBitsPerPixel(); / 获取每像素的位数 147 LPDISPATCH GetThumbnail( lo
11、ng ThumbSize); / 返回 IPictureDisp,获取图象指图 148 LPDISPATCH GetPicture(); / 获取图象返回 IPictureDisp 149 long GetCompression(); / 获取图片压缩程度 150 void OCR( long LangId, BOOL OCROrientImage, BOOL OCRStraightenImage); / 对页面执行 OCR 151 void Rotate( long Angle); / 转动页面增加 90 度 152 ;153 / /154 / IImages wrapper class 1
12、55 156 class IImages : public COleDispatchDriver157 158 public :159 IImages() / Calls COleDispatchDriver default constructor 160 IImages(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 161 IImages( const IImages 169 void Add(LPDISPATCH Page, LPDISPATCH BeforePage);170 LPUNKNOWN Get_NewEnum();1
13、71 LPDISPATCH GetItem( long Index);172 void Remove(LPDISPATCH Page);173 ;174 / /175 / IDocument wrapper class 176 177 class IDocument : public COleDispatchDriver178 179 public :180 IDocument() / Calls COleDispatchDriver default constructor 181 IDocument(LPDISPATCH pDispatch) : COleDispatchDriver(pDi
14、spatch) 182 IDocument( const IDocument / 保存文挡 190 void Close(BOOL SaveChanges); / 关闭文挡 191 void SaveAs(LPCTSTR FileName, long FileFormat, long CompLevel); / 以指定文件名,图片格式,压缩程度来保存文挡 192 LPDISPATCH GetImages(); / 获取文挡页面收集 193 LPDISPATCH GetBuiltInDocumentProperties(); / 获取 Office 文挡属性 194 LPDISPATCH Get
15、CustomDocumentProperties(); / 获取 Office 文挡属性 195 void Create(LPCTSTR FileOpen); / 创建新的文挡 196 BOOL GetDirty(); / 获得一个值,看是否不保存所修改过的文挡 197 void OCR( long LangId, BOOL OCROrientImage, BOOL OCRStraightenImage); / 对整个文挡执行 OCR 198 void PrintOut( long From, long To, long Copies, LPCTSTR PrinterName, LPCTSTR
16、 PrintToFileName, BOOL PrintAnnotation, long FitMode); / 打印文挡到打印机或者文件 199 ;200 / /201 / _IDocumentEvents wrapper class 202 203 class _IDocumentEvents : public COleDispatchDriver204 205 public :206 _IDocumentEvents() / Calls COleDispatchDriver default constructor 207 _IDocumentEvents(LPDISPATCH pDisp
17、atch) : COleDispatchDriver(pDispatch) 208 _IDocumentEvents( const _IDocumentEvents 217 / /218 / _IImageEvents wrapper class 219 220 class _IImageEvents : public COleDispatchDriver221 222 public :223 _IImageEvents() / Calls COleDispatchDriver default constructor 224 _IImageEvents(LPDISPATCH pDispatch
18、) : COleDispatchDriver(pDispatch) 225 _IImageEvents( const _IImageEvents 233 / /234 / IMiSelectRect wrapper class 235 236 class IMiSelectRect : public COleDispatchDriver237 238 public :239 IMiSelectRect() / Calls COleDispatchDriver default constructor 240 IMiSelectRect(LPDISPATCH pDispatch) : COleDi
19、spatchDriver(pDispatch) 241 IMiSelectRect( const IMiSelectRect / 获取当前所显示页面 249 long GetLeft(); 250 long GetTop();251 long GetRight();252 long GetBottom();253 ;254 / /255 / IMiSelectRects wrapper class 256 257 class IMiSelectRects : public COleDispatchDriver258 259 public :260 IMiSelectRects() / Call
20、s COleDispatchDriver default constructor 261 IMiSelectRects(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 262 IMiSelectRects( const IMiSelectRects 270 LPUNKNOWN Get_NewEnum();271 LPDISPATCH GetItem( long Index);272 ;273 / /274 / IMiSelectableItem wrapper class 275 276 class IMiSelectableItem
21、 : public COleDispatchDriver277 278 public :279 IMiSelectableItem() / Calls COleDispatchDriver default constructor 280 IMiSelectableItem(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 281 IMiSelectableItem( const IMiSelectableItem / 拷贝所选择文本到剪贴板 289 CString GetText(); / 获取选择区域所辨认出的文本 290 LPDIS
22、PATCH GetWords(); / 获得所辨认出的文本的字符集合 291 LPDISPATCH GetSelectRects(); / 返回一个选择区域 292 ;293 / /294 / IMiSelectableImage wrapper class 295 296 class IMiSelectableImage : public COleDispatchDriver297 298 public :299 IMiSelectableImage() / Calls COleDispatchDriver default constructor 300 IMiSelectableImage
23、(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 301 IMiSelectableImage( const IMiSelectableImage / 拷贝所选择文本到剪贴板 309 LPDISPATCH ExportToPicture( long CopyAnnotation, long AlwaysKeepAnnotationColor); / 返回一个 IPictureDisp 图形选择 310 void GetBoundingRect( long * plPageNum, long * Left, long * Top, lo
24、ng * Right, long * Bottom); / 返回一个矩形区域 311 ;312 / /313 / IMiDocView wrapper class 314 315 class IMiDocView : public COleDispatchDriver316 317 public :318 IMiDocView() / Calls COleDispatchDriver default constructor 319 IMiDocView(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 320 IMiDocView( c
25、onst IMiDocView / 获取文挡 328 void SetDocument(LPUNKNOWN newValue); / 设置文挡 329 CString GetFileName(); / 获取文件名 330 void SetFileName(LPCTSTR lpszNewValue); / 设置文件名 331 long GetNumPages(); / 获取文挡的页数 332 void ClientToDocument( long * plX, long * plY); / 转换视图坐标到文挡坐标 333 void DocumentToClient( long * plX, lo
26、ng * plY); / 转换文挡坐标到视图坐标 334 void ClientToImage( long lSX, long lSY, long * pnPage, long * plX, long * plY); / 转换视图坐标到页面坐标 335 void ImageToClient( long nPage, long lX, long lY, long * plSX, long * plSY); / 页面坐标转换为视图坐标 336 void GetVisibleRect( long * Left, long * Top, long * Right, long * Bottom); /
27、返回可视矩形坐标 337 void MoveRectIntoView( long Left, long Top, long Right, long Bottom); / 移动指定的矩形区域到视图 338 long GetDocViewMode(); / 获得决定显示页面的方式 339 void SetDocViewMode( long nNewValue); / 设置决定以什么的方式去显示页面 340 long GetPageNum(); / 获取当前所显示页面 341 void SetPageNum( long nNewValue); / 设置当前所显示页面 342 void GetScal
28、e( double * pdScaleX, double * pdScaleY); / 获取被使用坐标因素 343 void SetScale( double dScaleX, double dScaleY); / 设置被使用坐标因素 344 long GetFitMode(); / 设置确定怎么适合页面到视图窗口值 345 void SetFitMode( long nNewValue); / 获取确定怎么适合页面到视图窗口值 346 long GetActionState(); / 获取运行操作状态 347 void SetActionState( long nNewValue); / 设
29、置允许操作状态 348 LPDISPATCH GetTextSelection(); / 获取用户选择区域 349 void SetTextSelection(LPDISPATCH newValue); / 设置用户选择区域 350 LPDISPATCH GetImageSelection(); / 获取用户选择,并以 Image返回 351 void SetImageSelection(LPDISPATCH newValue); / 设置用户选择,并以Image 返回 352 void SelectAll( long nPage); / 在页面上选择所有东西 353 void MoveSel
30、ectionToView(LPDISPATCH pdispSelection); / 移动用户所选对象到视图 354 void SetLayerVisible( long Index, BOOL bNewValue); / 设置文挡可视图层 355 BOOL GetLayerVisible( long Index); / 获取文挡可视图层 356 ;357 / /358 / _IMiDocViewEvents wrapper class 359 360 class _IMiDocViewEvents : public COleDispatchDriver361 362 public :363
31、_IMiDocViewEvents() / Calls COleDispatchDriver default constructor 364 _IMiDocViewEvents(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) 365 _IMiDocViewEvents( const _IMiDocViewEvents & dispatchSrc) : COleDispatchDriver(dispatchSrc) 366 367 / Attributes 368 public :369 370 / Operations 371 pub
32、lic :372 / method FitmodeChanged not emitted because of invalid return type or parameter type373 / method ScaleChanged not emitted because of invalid return type or parameter type374 / method SelectionChanged not emitted because of invalid return type or parameter type375 / method PageChanged not em
33、itted because of invalid return type or parameter type376 / method PageCountChanged not emitted because of invalid return type or parameter type377 / method CurPageNumChanged not emitted because of invalid return type or parameter type378 / method VisibleRectChanged not emitted because of invalid return type or parameter type