Using the Microsoft Office Document Imaging 2003 Object Model
The Microsoft® Office Document Imaging 2003 (MODI) object model makes it possible to develop custom applications for managing document images (such as scanned and faxed documents) and the recognizable text that they contain.
Important The MODI programmability features described in this document are available only in Microsoft Office Document Imaging 2003. The Microsoft Office XP version of Document Imaging did not include a programmable object model.
Using the MODI Library in a Development Project
To use MODI automation, set a reference in your project to the Microsoft Office Document Imaging 11.0 Type Library.
Overview of the MODI Object Model
The MODI object model consists of the following objects, their members, and dependent objects:
- The Document object represents an ordered collection of pages (images).
- The Image object represents a single page of a document.
- The Layout object exposes the results of optical character recognition (OCR) on a page.
- The MiDocSearch object exposes document search functionality.
- The viewer control (the MiDocView object) is an ActiveX® control that displays the pages of a document.
The Document Object
The MODI Document object represents an ordered collection of document images saved as a single file. You can use the Create method to load an existing MDI or TIF file, or to create an empty document that you can populate with images from other documents. The OCR method performs OCR on all pages in the document, and the OnOCRProgress event reports the status of the operation and allows the user to cancel it. The Dirty property lets you know whether your document has unsaved OCR results or changes. The SaveAs method allows you to specify an image file format and a compression level. You can also use the PrintOut method to print the document to a printer or a file.
Document Properties, Methods, and Events
|BuiltInDocumentProperties||An Office DocumentProperties collection.|
|CustomDocumentProperties||An Office DocumentProperties collection.|
|Dirty||A value that indicates whether the document has unsaved changes.|
|Images||The document's collection of pages.|
|Close||Closes the document.|
|Create||Creates a new document.|
|OCR||Performs OCR on the entire document.|
|PrintOut||Prints the document to a printer or file.|
|Save||Saves the document.|
|SaveAs||Saves the document with the specified file name, image format, and compression level.|
|OnOCRProgress||Reports the progress of OCR.|
The Image Object
The MODI Image object represent a single page image. The image exposes several properties that describe its dimensions and format. You can also display the page or its thumbnail in a control of your choice by using the standard IPictureDisp reference returned by the image's Picture and Thumbnail properties.
Image Properties, Methods, and Events
|BitsPerPixel||The bits per pixel.|
|Compression||The compression level.|
|Layout||The results of OCR on the page.|
|Picture||The image as an IPictureDisp.|
|PixelHeight||The height in pixels.|
|PixelWidth||The width in pixels.|
|Thumbnail||The image thumbnail as an IPictureDisp.|
|XDPI||The X-axis pixels per inch.|
|YDPI||The Y-axis pixels per inch.|
|OCR||Performs OCR on the page.|
|Rotate||Rotates the page in 90-degree increments.|
Through the image's Layout property, you gain access to the text that OCR has recognized on the page.
The Layout Object
The MODI Layout object provides summary information (such as the number of words) about the recognized text on the page and gives access to the recognized text itself and to each individual word in the text. The Word object exposes additional information about each word's font, its location on the page, and even the OCR engine's RecognitionConfidence factor, which estimates the likelihood of a recognition error.
Layout Properties, Methods, and Events
|Language||The language setting used by the OCR process.|
|NumChars||The number of characters in the recognized text.|
|NumFonts||The number of fonts in the recognized text.|
|NumWords||The number of words in the recognized text.|
|Text||The recognized text as a single string.|
|Words||The recognized text as a collection of words.|
Word Properties, Methods, and Events
|Font||The MiFont used by the word.|
|FontId||The index into the implicit fonts collection.|
|Id||The index into the page's Words collection.|
|LineId||The index into the implicit lines collection.|
|RecognitionConfidence||The OCR engine's recognition confidence factor.|
|Rects||The bounding rectangles that include the word.|
|RegionId||The index into the implicit regions collection.|
|Text||The text of the word.|
MiFont Properties, Methods, and Events
|FaceStyle||Font face style; for example, "bold".|
|Family||Font family; for example, "Times New Roman".|
|FontSize||Font size in points.|
|SerifStyle||Font serif style; for example, "thin".|
The MiDocSearch Object
The MODI MiDocSearch object provides the ability to search for a word or phrase in the recognized text on the page.
The MiDocView Object
The MODI MiDocView object represents the MODI viewer control, an ActiveX control that you can use to display and scroll through a MODI document. You can manipulate the scaling of the document in the window, scroll the image programmatically, retrieve the user's selection as text or as an image, and return information about the contents of the viewer window and its coordinates.
See Using the Microsoft Office Document Imaging 2003 Viewer Control for additional information.
Using the MODI Object Model
The MODI object model makes it possible to automate many types of document management tasks. Here are just a few examples:
- Automating the rollup of multiple single-page scanned image files into a single compressed multiple-page document file
- Automating OCR operations on entire folders of documents
- Automating the searching of scanned documents such as resumes for certain words and phrases
Limitations of the MODI Object Model
MODI automation provides powerful document management and OCR features; however, it does not automate the document scanning process itself or support image annotation.