Browse our Products
Latest release
This article contains a summary of recent changes, enhancements and bug fixes in Aspose.OCR for Node.js via C++ 23.12.0 (December 2023) 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
- Create a directory somewhere on your system where the project files will be kept.
This directory will later be referred as project directory. - Create node_modules directory in the project directory.
- Download Aspose.OCR for Node.js via C++ distributive.
- Unpack the downloaded package to aspose-ocr directory inside node_modules directory.
- 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
- Open the command prompt and navigate to the project directory.
- Run index.js script with the following command:
node --no-experimental-fetch index
- Wait for recognition to complete. It may take a while depending on the image size and your system performance.