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.
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.
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.
C# code
// Specify the path to the ABBYY FineReader Engine Library (freRootPath)// before initializingFREngine.FREngine.SetFREnginePath ( freRootPath );// Loading the Engine objectengine = FREngine.FREngine.InitializeEngine( customerProjectId, licensePath, licensePassword, "", "", false ); ...// Unloading the Engine objectif ( engine == null ){ // Engine was not loaded return;}engine = null;GC.Collect();GC.WaitForPendingFinalizers();GC.Collect();FREngine.FREngine.DeinitializeEngine();
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):
С# code
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.SamplesSee the Hello code sample illustrating ABBYY FineReader Engine functioning in .NET Core.