Skip to main content
This topic applies to FRE for Windows .
To run your .NET Core application in different operating systems and containers, ABBYY FineReader Engine provides you with the ready-to-use .NET Core wrapper for the Engine library. This wrapper allows you to directly access the ABBYY FineReader Engine API, which is the same for all platforms with some minor exceptions. One notable limitation is that objects implementing IEngineLoader are not available on Linux (See Differences between ABBYY FineReader Engine 12 for Windows and for Linux for the full list of differences).
In this release, the .NET Core wrapper does not support working with InprocLoader and OutprocLoader objects.
To use your application in containers, include it with .NET Core Runtime in the container image. See details for deploying ABBYY FineReader Engine in Docker container in Running ABBYY FineReader Engine 12 inside a Docker container.

Adding ABBYY FineReader Engine library to a .NET Core project

ABBYY FineReader Engine includes the FREngine.DotNet.Interop.dll file, which contains the .NET Core wrapper for FineReader Engine. You can find this file in the Bin or Bin64 folder of the installation folder. You should add FREngine.DotNet.Interop.dll to the dependencies assembly in your project and redistribute it with your ABBYY FineReader Engine-based application.
The only supported version of .NET Core is 6.

Loading and unloading ABBYY FineReader Engine

To initialize the Engine object, set the path to FREngine.dll with the SetFREnginePath method of the static FREngine class, then use the InitializeEngine function of the same class. To unload the Engine object, use the DeinitializeEngine function.
// Specify the path to the ABBYY FineReader Engine Library (freRootPath)
// before initializing
FREngine.FREngine.SetFREnginePath ( freRootPath );
// Loading the Engine object
engine = FREngine.FREngine.InitializeEngine( customerProjectId, licensePath, licensePassword, "", "", false );    
...
// Unloading the Engine object
if ( engine == null )
{
   // Engine was not loaded
   return;
}
 
engine = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
 
FREngine.FREngine.DeinitializeEngine();

Collecting garbage

All objects in the .NET Core wrapper are derived from the IDisposable interface, which is responsible for releasing the resources allocated for objects. Implementing this interface ensures the collecting of the garbage automatically when an object is no longer needed. It is necessary to use the using statement for finishing with the objects, especially with heavy objects related to the document processing, synthesis, or export, such as IFRDocument, IFRPages, PDFExportParams, etc. (see the example below):
using (FREngine.FRDocument document = engineLoader.Engine.CreateFRDocument()) 
{
   try 
   {
     // Add image file to a document
     Console.WriteLine("Loading image...");
     document.AddImageFile(imagePath, null, null);
     ...
     // Save results to PDF using 'balanced' scenario
     using (FREngine.PDFExportParams pdfParams = engineLoader.Engine.CreatePDFExportParams()) 
     {
       pdfParams.Scenario = FREngine.PDFExportScenarioEnum.PES_Balanced;
       document.Export(Path.Combine(FreConfig.GetSamplesFolder(), @"SampleImages\Demo.pdf"),
       FREngine.FileExportFormatEnum.FEF_PDF, pdfParams);
     }
   }
}
In case you prefer not to use the using statement, explicitly call the Dispose method. Samples See the Hello code sample illustrating ABBYY FineReader Engine functioning in .NET Core.