Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leadtools - OcrException - ocr Not Enabled

I am using Leadtools OCR

I referenced the following DLLS:

Leadtools.dll
Leadtools.Barcode.oneD.dll
Leadtools.codecs.dll
Leadtools.codecs.fax.dll
Leadtools.codecs.png.dll
Leadtools.codecs.tif.dll
Leadtools.Forms.DocumentWriters.dll
Leadtools.forms.ocr.dll
Leadtools.forms.ocr.Advantage.dll

And the following code to convert a Png file to Pdf

private void button1_Click(object sender, EventArgs e)
{

    try
    {

        string sourceFile = @"C:\Users\cf\Desktop\OcrTest\Images\Capture.PNG";
        string targetFile = Path.ChangeExtension(sourceFile, "pdf");

        using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
        {
            ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");
            ocrEngine.AutoRecognizeManager.Run(sourceFile, targetFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, null, null);
            Process.Start(targetFile);

        }
    }

    catch (OcrSupportLockedException ex)
    {
        Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType);
    }
    catch (OcrException ex)
    {
        Console.WriteLine("OCR Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
    }
    catch (RasterException ex)
    {
        Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("System Error\nMessage:{0}", ex.Message);
    }


}

The following line is returning an OcrException

Ocr Not Enabled

With the code: -1760

I cant figure out why this is happening

Any help would be appreciated

like image 202
HelpASisterOut Avatar asked Jul 12 '26 17:07

HelpASisterOut


1 Answers

Error -1760 "OCR not enabled" is most likely caused by trying to use one of LEADTOOLS OCR engines without an appropriate license file or unlock key. You could check before using CreateEngine() by calling RasterSupport.IsLocked( RasterSupportType.OcrAdvantage ). If the function returns TRUE, which means Locked, you should not try to use the OCR features.

To use OCR, you need to either own a valid toolkit license with OCR support in it, such as LEADTOOLS Document Imaging Suite, or have a valid free evaluation license.

The mechanism to enable OCR features depends on the toolkit version. If you already have a valid unlock key (v17 and earlier) or valid license file (version 17.5 and later), but it still fails, please send that license/unlock information to [email protected], since you should not post such details on a public forum.

If you don't have these details, send your toolkit serial number to [email protected] (also don't post it here!) You can also use our online chat service during working hours to contact support or sales.

like image 64
LEADTOOLS Support Avatar answered Jul 15 '26 07:07

LEADTOOLS Support



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!