Browse our Products

Latest release

What was changed

This is the first released version of Aspose.OCR for Node.js via C++ library. As such, it contains no new features, improvements, or fixes from previous releases.

Stay tuned for further updates!

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for Node.js via C++ 23.12.0 that may affect the code of existing applications.

Added public APIs:

First release.

Updated public APIs:

First release.

Removed public APIs:

First release.

Get started

The example below illustrates how to use the library on your web page.

Prepare the environment

  1. Create a directory somewhere on your system where the project files will be kept.
    This directory will later be referred as project directory.
  2. Create node_modules directory in the project directory.
  3. Download Aspose.OCR for Node.js via C++ distributive.
  4. Unpack the downloaded package to aspose-ocr directory inside node_modules directory.
  5. Put a sample image to the project directory under the name source.png.

Create a project script

Create an index.js file in the the project directory which will be used as a main (startup) project script:

const Module = require("aspose-ocr/lib/asposeocr");
const fs = require("fs");

Module.onRuntimeInitialized = async _ => {
   // Load image file
   fs.readFile("source.png", (err, imageData) => {
      // Save image to the virtual storage
      const imageBytes = new Uint8Array(imageData);
      let internalFileName = "temp";
      let stream = Module.FS.open(internalFileName, "w+");
      Module.FS.write(stream, imageBytes, 0, imageBytes.length, 0);
      Module.FS.close(stream);
      // Add image to recognition batch
      let source = Module.WasmAsposeOCRInput();
      source.url = internalFileName;
      let batch = new Module.WasmAsposeOCRInputs();
      batch.push_back(source);
      // Specify recognition language
      let recognitionSettings = Module.WasmAsposeOCRRecognitionSettings();
      recognitionSettings.language_alphabet = Module.Language.ENG;
      // Send image for OCR
      var result = Module.AsposeOCRRecognize(batch, recognitionSettings);
      // Output image text to the console
      var text = Module.AsposeOCRSerializeResult(result, Module.ExportFormat.text);
      console.log(text);
   });
}

Run the example

  1. Open the command prompt and navigate to the project directory.
  2. Run index.js script with the following command:
    node --no-experimental-fetch index
  3. Wait for recognition to complete. It may take a while depending on the image size and your system performance.