1. Products
  2.   OCR
  3.   Node.js
  4.   Aspose.OCR library for Node.js via C++

Aspose.OCR library for Node.js via C++

 
 

Node.js OCR Library to Recognize/Extract Image's Text

To Node.js OCR API enables Software Developers to Extract ofText from Images, Scanned Documents, Photos & Screenshots as well as Automate Tasks That Involve Text Recognition.

Aspose.OCR library for Node.js via C++ is a powerful library that provides optical character recognition (OCR) capabilities for software developers working with Node.js applications. This library is part of the Aspose suite, which is renowned for its robust and reliable document processing solutions the primary feature of is its ability to recognize and extract text from images, scanned documents, photos, screenshots, and so on. The library can also recognize handwritten text in addition to printed text, expanding its usability to a wider range of documents. In addition to extracting plain text, It can also preserve the formatting of the recognized text, including font styles, sizes, and colors.

One of the standout features of Aspose.OCR for Node.js Library is its support for multiple image formats, including JPEG, PNG, BMP, TIFF and many more. This versatility allows software developers to work with a wide range of images, making it easier to process various types of documents and graphics. Furthermore, it offers advanced OCR algorithms that ensure accurate and reliable text extraction. By leveraging sophisticated recognition techniques, the library can effectively interpret text from images, even in cases where the text is skewed, blurred, or distorted.

Aspose.OCR for Node.js supports multiple languages, making it suitable for global applications. It can recognize text in more than 130 languages including, English, Spanish, French, German, Italian, Portuguese, Chinese, Japanese, and many others. Designed with performance and scalability in mind, the library can handle large volumes of images efficiently. It allows developers to define custom templates for structured documents. This feature is useful for extracting specific fields from forms, invoices, and other templated documents. Overall, Aspose.OCR Library is a valuable tool for developers looking to incorporate OCR functionality into their Node.js applications.

Previous Next

Getting Started with AAspose.OCR library for Node.js via C++

The recommend way to install Aspose.OCR library for Node.js via C++ is using npm. Please use the following command for a smooth installation.

Install Aspose.OCR library for Node.js via C++ via npm

 npm install aspose-ocr-cloud 

You can download the library directly from Aspose.OCR product page

Aspose.OCR library for Node.js via C++ has provided complete functionality for performing optical character recognition (OCR) operations on various images. With just a couple of lines of code software developers can recognize and extract text from images inside Node.js applications. The API has included support various popular image file formats, such as JPEG, PNG, GIF, TIFF, PDF, BMP, and many more. There are several important features part of the library such as recognition of rotated, skewed and noisy images. Moreover, software developers can save the recognition results in the most popular document and data exchange formats. The following example shows how JavaScript commands can be used to load and extract text from an image.

How to Recognize Text from an Image in Node.js Apps?

let source = Module.WasmAsposeOCRInput();
source.url = internalFileName;
let batch = new Module.WasmAsposeOCRInputs();
batch.push_back(source);

// Send image for OCR
var result = Module.AsposeOCRRecognize(batch);
// Output extracted text to the console
var text = Module.AsposeOCRSerializeResult(
              result, Module.ExportFormat.text);

console.log(text);

Handwritten Text Recognition in Node.js Apps

Aspose.OCR library for Node.js via C++ makes it easy for software developers to recognize handwritten text inside their own Node.js applications. It can recognize handwritten text in addition to printed text, expanding its usability to a wider range of documents. Software developers can recognize handwritten text by enabling the handwritten text mode. It is also possible to recognize an image from URL without downloading it locally. The following example shows, how software developers can load and recognize handwritten text inside node.js applications.

How to Recognize Handwritten Text inside Node.js Apps

const recognizeHandwritten = true;

ocrApi.recognizeFromContent('eng', recognizeHandwritten, imageBuffer, (error, data) => {
  if (error) throw error;

  console.log('Extracted Handwritten Text:', data.text);
});

Template-Based Recognition Support

Template-based recognition involves defining a template that specifies the layout and areas of interest in a document. Template-based recognition with Aspose.OCR for Node.js via C++ provides a structured and accurate way to extract data from documents with fixed layouts. This feature is useful for extracting specific fields from forms, invoices, and other templated documents. Here is a very useful example that shows how software developers can load the template and apply it to an image for OCR inside Node.js apps.

How to Load the Template and Apply It to an Image for OCR inside Node.js Apps?

const fs = require('fs');
const { OcrApi, AsposeApp, TemplateApi } = require('aspose-ocr-cloud');

const appSid = 'your-app-sid';
const appKey = 'your-app-key';

AsposeApp.appSID = appSid;
AsposeApp.appKey = appKey;

const ocrApi = new OcrApi();
const templateApi = new TemplateApi();

const imagePath = 'path/to/your/invoice.jpg';
const templatePath = 'path/to/your/template.json';

fs.readFile(imagePath, (err, imageBuffer) => {
  if (err) throw err;

  fs.readFile(templatePath, (err, templateBuffer) => {
    if (err) throw err;

    // Load the template
    templateApi.addTemplate(templateBuffer, (error, templateId) => {
      if (error) throw error;

      // Apply the template to the image
      ocrApi.recognizeFromTemplate(imageBuffer, templateId, (error, result) => {
        if (error) throw error;

        console.log('Extracted Data:', result.fields);
      });
    });
  });
});

Preserve Text Formatting in OCR Operations

Preserving text formatting during OCR operations is crucial for applications where the structure, font styles, and layout of the text are important. In addition to extracting plain text, Aspose.OCR for Node.js via C++ can also preserve the formatting of the recognized text, including font styles, sizes, and colors. This is particularly useful for processing documents where text formatting is crucial. Below is an example demonstrating how software developers can preserve text formatting using Aspose.OCR API.

How to Preserve Text Formatting in OCR Operations inside Node.js Apps?

const fs = require('fs');
const { OcrApi, AsposeApp, OCRFormat, OCRRecognitionSettings } = require('aspose-ocr-cloud');

const appSid = 'your-app-sid';
const appKey = 'your-app-key';

AsposeApp.appSID = appSid;
AsposeApp.appKey = appKey;

const ocrApi = new OcrApi();

const imagePath = 'path/to/your/document.jpg';

fs.readFile(imagePath, (err, imageBuffer) => {
  if (err) throw err;

  const recognitionSettings = new OCRRecognitionSettings();
  recognitionSettings.setDetectAreas(true);
  recognitionSettings.setDetectText(true);
  recognitionSettings.setDetectItalic(true);
  recognitionSettings.setDetectBold(true);

  ocrApi.recognizeWithSettings(imageBuffer, OCRFormat.TEXT, recognitionSettings, (error, data) => {
    if (error) throw error;

    const formattedText = data.text;
    const formattingDetails = data.textAreas;

    console.log('Extracted Text with Formatting:', formattedText);
    console.log('Formatting Details:', formattingDetails);
  });
});