Ask AI
Table of contents

Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!

Your download will start shortly. If your download does not begin, click here to retry.

{WebTwainObject}.Addon.OCRConnector

{WebTwainObject} denotes the WebTwain instance.

Methods

GetInstalledOCRInfo() DetectPageOrientation() Recognize() SaveToPath()
SaveAsBase64() SaveAsBlob()    

GetInstalledOCRInfo()

Return the info of the installed OCR addon. It contains a list of OCR engines and their supported languages.

Syntax

GetInstalledOCRInfo(): Promise<OCRInfo>;

Return Values

Promise of an OCRInfo object.

Availability

Windows macOS Linux
v19.3+ v19.5+ not supported

DetectPageOrientation()

Detect the orientation of a page.

Syntax

DetectPageOrientation( 
  index: number,  
  settings?: { 
    engine?: {
      name: string; 
    },
    detectionMode?: EnumDWT_PageOrientationDetectionMode | number
  }
): Promise<{angle: EnumDWT_PageOrientation | number, confidence: number}>; 

Parameters

index: Index of the image to process.

settings: Settings of the method. You can configure the accuracy mode and which OCR engine to use. Please refer to EnumDWT_PageOrientationDetectionMode. Currently, only the Onnx.Ocr engine supports this and it is used by default if installed.

Return Values

Promise of an object of the orientation detection result. Please refer to EnumDWT_PageOrientation.

Availability

Windows macOS Linux
v19.3+ not supported not supported

Recognize()

Recognize the text in one page. You can specify the engine and the language; their values can be retrieved via GetInstalledOCRInfo().

Syntax

Recognize( 
  index: number,
  options?: {
    engine?: { 
      name :string 
    },
    settings?: { 
      language?: string,
      pageOrientation?: EnumDWT_PageOrientation| number,
      recognitionLevel?: "accurate" | "fast",
    },
    rects?: { 
      left: number, 
      top: number, 
      right: number, 
      bottom: number
    }[]
  }
): Promise<OCRResult>;  

Parameters

index: Index of the image to process.

options:

  • engine: The OCR engine to use.
  • settings: Settings of the recognition.
    • language: Specify the code of language for recognition. See the table to learn about supported languages.
    • pageOrientation: Specify the orientation of the page. The OCR will rotate the page before recognition. Please refer to EnumDWT_PageOrientation. Only the Onnx.Ocr engine supports this setting.
    • recognitionLevel: Specify the recognition level for the OCR. It is only valid for macOS.
  • rects: An array of rectangles to limit the regions for recognition.

Return Values

Promise of the OCRResult object.

Availability

Windows macOS Linux
v19.3+ v19.5+ not supported

SaveToPath()

Save the result to a local path.

Syntax

SaveToPath(
  indices: number[],  
  outputFormat: Dynamsoft.DWT.EnumDWT_OCRConnectorOutputFormat | number,  
  path: string
): Promise<boolean>;

Parameters

indices: Indices of the pages to save.

outputFormat: Please refer to EnumDWT_OCRConnectorOutputFormat.

path: System’s absolute path or filename for saving. A file saving dialog will appear for confirmation.

Return Values

Promise of a boolean result indicating the success of the operation.

Availability

Windows macOS Linux
v19.3+ v19.5+ not supported

SaveAsBase64()

Save the result as base64.

Syntax

SaveAsBase64(
  indices: number[],
  outputFormat: Dynamsoft.DWT.EnumDWT_OCRConnectorOutputFormat | number
): Promise<string>;

Parameters

indices: Indices of the pages to save.

outputFormat: Please refer to EnumDWT_OCRConnectorOutputFormat.

Return Values

Promise of a base64 string result.

Availability

Windows macOS Linux
v19.3+ v19.5+ not supported

SaveAsBlob()

Save the result as blob.

Syntax

SaveAsBlob(
  indices: number[],  
  outputFormat: Dynamsoft.DWT.EnumDWT_OCRConnectorOutputFormat | number
): Promise<Blob>;

Parameters

indices: Indices of the pages to save.

outputFormat: Please refer to EnumDWT_OCRConnectorOutputFormat.

Return Values

Promise of a Blob object.

Availability

Windows macOS Linux
v19.3+ v19.5+ not supported