Using ABBYY FineReader Engine in C (Objective-C)

This section provides the description of loading and unloading ABBYY FineReader Engine in C (Objective-C).

  1. Include this code when importing the FREngine.h header file:
/* C */
#define __RPC__deref_out
#define COBJMACROS
#include <FREngine.h>
/* Objective-C */
#define interface _COM_interface
#define __RPC__deref_out
#define COBJMACROS
#import <FREngine.h>
#undef interface
    
  1. Use the following code for loading and unloading FREngine.dll:
typedef HRESULT (*initializeEngine_ptr) (BSTR, BSTR, BSTR, BSTR, BSTR, VARIANT_BOOL, IEngine **);
typedef HRESULT (*DeinitializeEngine_ptr) (void);
static IEngine* FREngine;
static HMODULE FREngineDll;
int main(int argc, char *argv[]) {
 initializeEngine InitializeEngine=NULL;
 DeinitializeEngine_ptr DeinitializeEngine=NULL;
 // provide your Customer Project ID here, and if applicable, the Online License information
 wchar_t *customerProjectId = L"";
 wchar_t *licensePath = L"";
 wchar_t *licensePassword = L"";
 FREngineDll = LoadLibraryEx("<path to FREngine.dll>", 0, LOAD_WITH_ALTERED_SEARCH_PATH);
 if(FREngineDll) {
  InitializeEngine = (InitializeEngine_ptr) GetProcAddress(FREngineDll,"InitializeEngine");
  if(InitializeEngine)
   InitializeEngine(customerProjectId, licensePath, licensePassword, "", "", FALSE, &FREngine);
 }
 ProcessImage();
 IEngine_Release( FREngine );
 DeinitializeEngine = (DeinitializeEngine_ptr) GetProcAddress(FREngineDll,"DeinitializeEngine");
 DeinitializeEngine();
}
    
  1. All other calls to ABBYY FineReader Engine can use the C macros defined in the FREngine.h header file.
void ProcessImage()
{
 IFRDocument* frDocument = NULL;
 IEngine_CreateFRDocument( FREngine, &frDocument );
 IFRDocument_AddImageFile( frDocument, L"<path to a source image>", NULL, NULL );
 IFRDocument_Process( frDocument, NULL, NULL, NULL );
 IFRDocument_Export( frDocument, L"<path to an output file>", FEF_PDF, NULL );
 IFRDocument_Release( frDocument );
}
    

See also

Programming Aspects

24.03.2023 8:51:52

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.