2015-05-22 26 views
3

我使用LEADTOOLS OCRLEADTOOLS - OcrException - OCR未启用

我引用下列DLL:

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 

以下代码为PNG文件转换为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); 
    } 


} 

以下行返回OcrException

Ocr Not Enabled 

随着代码:-1760

我无法弄清楚为什么发生这种情况

任何帮助,将不胜感激

回答

1

错误-1760“OCR没有启用”最有可能是试图用一个引起LEADTOOLS OCR引擎没有适当的许可证文件或解锁密钥。 您可以在使用CreateEngine()之前通过调用RasterSupport.IsLocked(RasterSupportType.OcrAdvantage)来检查。如果函数返回TRUE,表示锁定,则不应尝试使用OCR功能。

要使用OCR,您需要拥有一个有效的工具包许可证,其中包含OCR支持,例如LEADTOOLS Document Imaging Suite,或者拥有有效的免费评估许可证。

启用OCR功能的机制取决于工具包版本。如果您已拥有有效的解锁密钥(v17及更早版本)或有效的许可证文件(版本17.5及更高版本),但仍然失败,请将该许可证/解锁信息发送到[email protected],因为您不应发布此类详细信息在公共论坛上。

如果您没有这些详细信息,请将您的工具包序列号发送到[email protected](也不要在此发布!)您也可以在工作时间使用我们的在线聊天服务联系支持或销售。