Return >  Addon.OCR.DownloadLangData

Addon.OCR.DownloadLangData()

Description

Downloads the OCR language package from the server.

Syntax

.Addon.OCR.DownloadLangData(RemoteFile, [optionalAsyncSuccessFunc, optionalAsyncFailureFunc])

Parameters

<string> RemoteFile: specifies the url path of the language package on the HTTP server.

The following two parameters are optional. If either one exists or both exist, the method is asynchronous, otherwise it's synchronous.

<OnSuccess function> optional optionalAsyncSuccessFunc: callback function triggered when the file is downloaded successfully.
<OnFailure function> optional optionalAsyncFailureFunc: callback function triggered when downloading the file fails.

Please refer to the function prototype OnSuccess or OnFailure.

Return value

Only valid when used synchronously.

bool

true indicates success. false indicates failure.

Remarks

Please make sure the target language is already set with Addon.OCR.SetLanguage before you use this method.

Example

function btnOCR_onclick() {
 var filePath = "D:\\OCRResult\\OCResult.pdf";
 var strHTTPServer = location.hostname;
 var CurrentPathName = unescape(location.pathname);
 var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1);
 var appPath = "http://" + strHTTPServer + ":" + location.port + CurrentPath;
 
 DWObject.Addon.OCR.DownloadLangData(appPath +"Resources/addon/English.zip", function(){
  DWObject.Addon.OCR.Download(appPath +"Resources/addon/OCR.zip", 
   function () {
    DWObject.Addon.OCR.Recognize(DWObject.CurrentImageIndexInBuffer, 
     function (index,result) {
      result.Save(filePath);       
     },        
     function (errorCode, errorString) {alert(errorString);}
    );
   }, 
   function (errorCode, errorString) {alert(errorString); }
  );},
  function (errorCode, errorString) {alert(errorString); }
 );
}

See Also

Addon.OCR.SetLanguage