C#nuance omnipage OCR SDK Engine.SetLicenseKey()

时间:2016-02-05 15:51:39

标签: c# .net sdk ocr

即时通讯使用细微差别OCR SDK。

编译时遇到错误:引擎初始化错误,或没有相应的许可证。我发现可能我应该使用Engine.SetLicenseKey()方法。

我应该向Engine.SetLicenseKey()提供哪些文件和许可证密钥?

    try
    {
        List<OCR_Error> ocrErrors = new List<OCR_Error>();
        System.Console.Write("** Title: Nuance Capture Development System CSharp Sample01 Application **\n");
        System.Console.Write("Initializing the ENGine -- Engine.Init\n");
        Engine.SetLicenseKey("licenseFile.lcx", "licenseKey");
        Engine.Init("companyName", "projectName");
        if (Engine.RECERR == RECERR.API_INIT_WARN)
        {
            ocrErrors.Add(new OCR_Error()
            {
                Message = "Module initialization warning. One or more recognition modules haven't been initialized properly.",
                InnerMessage = "For more information, see Engine.ModulesInfo"
            });
            return;
        }
        string inputFileName = @"D:\3141864.pdf";
        string inputFilePath = Path.GetFullPath(inputFileName);
        string outputFilePath = inputFilePath.Replace('.', '_') + @".pdf";
        if (File.Exists(outputFilePath))
            File.Delete(outputFilePath);
        File.Create(outputFilePath);

        using (SettingCollection settings = new SettingCollection())
        {
            using (Document doc = new Document(inputFilePath))
            {
                int sourcePagesCount = doc.PageCount;
                for (int i = 0; i < sourcePagesCount; i++)
                {
                    using (Page page = new Page(inputFilePath, i, settings))
                    {
                        page.Preprocess();
                        page.Recognize();
                        using (Document oputputDocument = new Document(outputFilePath, 0, settings))
                        {
                            oputputDocument.InsertPage(page, i);
                            oputputDocument.Save(outputFilePath);
                        }
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        System.Console.Write(e.Message);//Error: License Manager error.
    }
    finally
    {
        System.Console.Write("Free all resources allocated by the Engine -- Engine.ForceQuit\n");
        Engine.ForceQuit();
        System.Console.Write("End of Sample01 application\n");
        System.Console.ReadKey();
    }

1 个答案:

答案 0 :(得分:1)

如果您购买了此软件,则应附带有关如何加载许可文件和密码的正确文档和/或支持。检查文档或联系他们。

如果您没有购买此软件,则似乎需要有效的许可文件和密钥。您可能需要购买许可证。

如果您在没有文档和支持的情况下购买此软件,请考虑您的资金丢失。