Using ABBYY FlexiCapture SDK in Delphi

This section deals with certain peculiarities of using ABBYY FlexiCapture SDK in Delphi.

Creating the Object Pascal Wrapper Unit

In order to use ABBYY FlexiCapture 12 SDK in Delphi, it is necessary to create the Object Pascal wrapper unit for the type library (the FCEngine_TLB.pas file). To generate the wrapper:

  1. Run command prompt (cmd.exe) and go to the folder where the ABBYY FlexiCapture 12 SDK type library (FCEngine.tlb) is located.
  2. Run the tlibimp utility with the following parameters:
tlibimp -O- -Cd- -C- -P+ -Pt+ FCEngine.tlb
    

This will generate the FCEngine_TLB.pas file.

  1. Add FCEngine_TLB.pas to your project.

You need to regenerate FCEngine_TLB.pas each time you receive an updated version of ABBYY FlexiCapture 12 SDK.

Using Engine loaders in Delphi 7

There is also an alternative way of using ABBYY FlexiCapture SDK in Delphi 7, for which you will not need to create the wrapper manually as described above. But this method is only suitable if you load the Engine object in your application using the Engine loaders.

  1. Open your project and choose Project > Import Type Library.
  2. In the dialog that opens choose ABBYY FlexiCapture 12 SDK Type Library in the list. Make sure that Generate Component Wrapper flag is turned on. Click Install.

Note: An error at this stage may indicate that the system environment variable Path does not contain the necessary paths. Modify it to include the path to the mscoree.tlb file (generally it is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

  1. New components appear on the ActiveX tab of the Components palette — InprocLoader and OutprocLoader. You can add one of these components directly onto your form and use it to load the Engine object.

For example, you add the InprocLoader component onto your form. The following code will be added automatically:

uses FCEngine_TLB;
type
  TForm1 = class(TForm)
    InprocLoader1: TInprocLoader;
    ...
    private
      { Private declarations }
    public
      { Public declarations }
    end;
    

In your implementation use the Load method of the InprocLoader object to load Engine:

engineLoader.Set_CustomerProjectId(GetCustomerProjectId);
engineLoader.Set_LicensePath(GetLicensePath);
engineLoader.Set_LicensePassword(GetLicensePassword);
engine := engineLoader.GetEngine();
    

When you no longer need FlexiCapture SDK functionality, unload the Engine using the Unload method of the loader object.

InprocLoader1.Unload;
    

Deinitialization of the Engine Object

If not all the objects which were created and used by the application have been deleted before the Engine object deinitialization, the "Engine deinitialization failed" exception is thrown. If all the objects have been deleted, the exception may be caused by the scavenger operation. In Delphi all objects with the nil value are deleted only after the exit from the procedure in which the objects were declared. Therefore, the entire ABBYY FlexiCapture SDK code must be inserted into a separate procedure, and this procedure must be called before the Engine object deinitialization.

Note: You can use the StartLogging method of the Engine object to get the list of objects that have not been deleted.

See also

Different Ways to Load the Engine Object

15.08.2023 13:19:30

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.