When creating an application with a user interface, you can use ABBYY FineReader Engine Visual Components. Visual Components provide ready-to-use blocks for constructing your own user interface for an OCR application.
You can show processing documents to the user of your application, allow the user to verify recognition results, and edit recognized text. Visual Components can be useful in all processing scenarios: a preview of the processing image may be shown in the Image Preprocessing scenario, text editing can be provided in the Document Conversion scenario, while verification is extremely useful in Field-Level Recognition scenario.
Let's look at the simple OCR application from the user interface point of view. A document goes through several processing steps:
- Image opening
You can show the opened image to the user and allow the user to navigate between pages of the processing document.
- Recognition
To extract text data from a document, the document needs to be recognized. You can show recognized text to the user and allow him to edit the text.
- Verification
The recognized text may need to be verified. You can show both the source image and the recognized text to the user in order that they can be compared.
- Export
The recognized document can be saved to a suitable storage format or opened in an external application.
Below follows a detailed description of the way to use ABBYY FineReader Engine Visual Components.
Step 1. Adding Visual Components to the form of your application
Visual Studio enables you to insert ActiveX controls into your dialog box. You can add Visual Components to the Toolbox window (the Toolbox is available from the View menu) and work with them:
- On the Tools menu, click Choose Toolbox Items (or Add/Remove Toolbox Items).
- In the dialog box that opens, click the COM Components tab and select the ABBYY DocumentViewer, ABBYY ImageViewer, ABBYY ZoomViewer, ABBYY TextEditor, and ABBYY TextValidator components.
- Click OK. Icons for the selected items are now available in the Toolbox. You can drag and drop each Visual Component icon onto a design view surface. This action also adds the fundamental code to create an instance of the Visual Component in the active project file.
- After you have added the Visual Component to a form, you can specify its properties available in Visual Studio. For example, the SettingsPath property of each component should be specified at design time.
Step 2. Synchronizing Visual Components
The Component Synchronizer component allows you to synchronize Visual Components in the application. That means that all viewing and editing operations will be processed synchronously in all connected components. To synchronize Visual Components:
- On form loading, create a new ComponentSynchronizer object.
- Use the DocumentViewer, ImageViewer, ZoomViewer, TextEditor, TextValidator properties of the ComponentSynchronizer object to connect the components to the synchronizer.
When a component is connected to the synchronizer through the API, Component Synchronizer works as described in How Component Synchronizer Works.
C#
Step 3. Loading ABBYY FineReader Engine
To start working with ABBYY FineReader Engine, you need to create the Engine object. To create the Engine object, you can use the InitializeEngine exported function. See also other ways to load Engine object. You may load the Engine object during image loading or form initialization.
C#
Step 4. Image opening
To display the image in the Visual Components, you should open it. You may implement the following procedure for image opening:
- To load images of a single document, you should create the FRDocument object and add images to it. You may do one of the following:
- Attach the document to Component Synchronizer using the Document property of the ComponentSynchronizer object.
The procedure can handle the "on click" event for a button that opens images.
C#
Step 5. Recognizing documents
Recognition of an image in Visual Components can be called either using the commands, available in components or using FineReader Engine API (see, for example, the Process method of the FRDocument object).
You may implement the following procedure for recognition:
- Recognize the document using the methods of the FRDocument object.
- The document has been changed not through Visual Components GUI, therefore you need to report the changes to Visual Components. Use the Update method of the FRPage object for each page in the document.
The procedure can handle the "on click" event for a button that calls recognition.
C#
Step 6. Verifying recognition results
The recognized data can be verified using the Text Validator component. It provides the user interface which allows you to check whether a character has been recognized correctly and correct it if necessary.
You may implement the following procedure for verification:
- Add the Text Validator component to the current form or create a new form for it.
- Attach the Text Validator component to Component Synchronizer. Use the TextValidator property of the ComponentSynchronizer object.
- Start the verification process using the Spell method of the TextValidator object.
C#
Step 7. Exporting results
The recognized document can be saved either by using commands available in the Document Viewer, or using FineReader Engine API.
For example, use the Export method of the FRDocument object by assigning the FileExportFormatEnum constant as one of the parameters. After you have finished your work with the FRDocument object, release all the resources that were used by this object. Use the IFRDocument::Close method. The procedure can handle the "on click" event for a button that calls export.
C#
Step 8. Unloading ABBYY FineReader Engine
After finishing your work with ABBYY FineReader Engine, you need to unload the Engine object. To do this, use the DeinitializeEngine exported function.
The procedure can handle the "on click" event for a button that closes the application window.
C#
You can find a sample implementation of the described procedure in the Visual Components sample.
See also
Customizing the Context Menu and Toolbar of a Visual Component
Using Visual Components in Different Versions of Visual Studio