Using the Microsoft Office Document Imaging 2003 Viewer Control
The Microsoft® Office Document Imaging Library 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. The MODI components include the MODI Viewer Control, an ActiveX® control that you can use to display MODI documents.
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 does not include a programmable object model.
Using the MODI Viewer Control in a Development Project
To make the viewer control available in the Toolbox, select Microsoft Office Document Imaging 11.0 Type Library in the Components dialog box in your development environment. This selection also sets a reference in your project to the Microsoft Office Document Imaging 11.0 Type Library and makes the entire MODI object model available for automation. The viewer control corresponds to the MiDocView object in the MODI object model.
See Using the Microsoft Office Document Imaging 2003 Object Model for additional information.
Overview of the MODI Viewer Control
You can use the viewer control to display and scroll through MODI documents. 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.
MiDocView (viewer control) Properties, Methods, and Events
|ActionState||The allowable actions. For example, "pan" and "select".|
|Document||The displayed document.|
|DocViewMode||A setting that determines how pages are displayed.|
|FileName||The file name of the document, if opened from a file.|
|FitMode||A value that determines how to fit a page into the viewer window.|
|ImageSelection||The user's selection returned as an image.|
|LayerVisible||The visible layer of the document.|
|NumPages||The number of pages in the document.|
|PageNum||The currently displayed page.|
|TextSelection||The user's selection as text.|
|ClientToDocument||Translates viewer coordinates to document coordinates.|
|ClientToImage||Translates viewer coordinates to page coordinates.|
|DocumentToClient||Translates document to viewer coordinates.|
|GetScale||Returns the scaling factor that is in use.|
|GetVisibleRect||Returns the coordinates of the visible rectangle.|
|ImageToClient||Translates page coordinates to viewer coordinates.|
|MoveRectIntoView||Moves the specified rectangle into view.|
|MoveSelectionToView||Moves the user's selection into view.|
|SelectAll||Selects everything on the page.|
|SetScale||Sets the scaling factor to be used.|
|CurPageNumChanged||Occurs when a different page is displayed.|
|FitmodeChanged||Occurs when the FitMode property has changed.|
|PageChanged||[Reserved for future use.]|
|PageCountChanged||Occurs when the document's page count has changed.|
|ScaleChanged||Occurs when the scaling factor has changed.|
|SelectionChanged||Occurs when the user has changed the selection.|
|VisibleRectChanged||Occurs when the visible rectangle has changed.|
Loading a Document into the Viewer Control
You can load a document into the viewer control by using either of the following properties:
- Set the control's FileName property to the name of an existing MDI or TIF file.
- Set the control's Document property to a document that is already loaded in memory. (In this case, the Filename property remains empty.)
Working with the User's Selection
You can retrieve the user's selection in the viewer control window as text through the TextSelection property (which returns an IMiSelectableItem object) or as an image through the ImageSelection property (which returns an IMiSelectableImage object).
IMiSelectableItem (text selection) Properties, Methods, and Events
|Text||The recognized text in the selection.|
|Words||A collection of the words in the recognized text.|
|CopyToClipboard||Copies the selection as text to the clipboard.|
|GetSelectRects||Returns a collection of bounding rectangles.|
IMiSelectableImage (image selection) Properties, Methods, and Events
|CopyToClipboard||Copies the selection as an image to the clipboard.|
|ExportToPicture||Returns the image selection as an IPictureDisp.|
|GetBoundingRect||Returns the bounding rectangle.|
Limitations of the MODI Viewer Control
MODI automation provides powerful document management and optical character recognition (OCR) features; however, it does not automate the document scanning process itself or support image annotation.