Working with COM Interfaces from a Scripting Language
ABBYY FineReader Engine 12 supports dynamic binding in COM interfaces:
- Almost all ABBYY FineReader Engine 12 interfaces are derived from IDispatch (the exceptions are some of the callback interfaces implemented on the client-side).
- Scripting languages (for example, VBScript and JScript) support only dynamic binding. Therefore, due to inheriting such interfaces from IDispatch the use of ABBYY FineReader Engine API from these languages requires minimal additional effort: only the Engine object cannot be created by using the COM method CoCreateObject. For loading the Engine use one of the methods of the IEngineLoader interface. This interface is implemented in two objects which provide, respectively, in-process and out-of-process loading of the Engine: InprocLoader and OutprocLoader. You can create either of these objects by methods provided in your scripting language and then call the InitializeEngine method to load the Engine.
- The other objects created by the methods of the Engine object named "Create..." or "Load..." can now be created and used directly from the scripting language.
- The IEngineLoader interface also provides a NullObject property which returns a reference to a null object. In scripting languages, null itself is not an object, but some methods need to receive null parameters for the default behavior. (For example, the IFRDocument::Analyze method can receive null instead of parameters objects, in which case the analysis is performed with default settings for the loaded profile.)
Important! Registration of FREngine.dll is necessary when installing the application on an end user's computer. To register FREngine.dll, use the following command line:
regsvr32 /s /n /i:"<path to the Inc folder>" "<path to FREngine.dll>"
// create the EngineLoader object var EngineLoader = new ActiveXObject( "FREngine.OutprocLoader" ); ... // get the Engine object var Engine = EngineLoader.InitializeEngine( CustomerProjectId, LicensePath, LicensePassword, "", "", false ); // provide your Customer Project ID, the path to the online license file and the online license password
In VBScript, use the CreateObject method:
' create the EngineLoader object Set EngineLoader = CreateObject( "FREngine.OutprocLoader" ) ... ' get the Engine object Set Engine = EngineLoader.InitializeEngine( CustomerProjectId, LicensePath, LicensePassword, "", "", False )
In Perl, use the CreateObject method:
# create the EngineLoader object $EngineLoader = $WScript->CreateObject( 'FREngine.OutprocLoader' ); ... # get the Engine object $Engine = $EngineLoader->InitializeEngine( CustomerProjectId, LicensePath, LicensePassword, '', '', 0 );