Skip to content

aspose-ocr-cloud/aspose-ocr-cloud-nodejs

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

GitHub license

Aspose.OCR Cloud Node.js SDK

Aspose.OCR Cloud is a simple SDK used to add text recognition to your app with merely a few lines of code.

In detail, it's a set of SDKs for optical character recognition and document scanning in our Cloud. It supports reading and recognizing text from most commonly used raster image formats. Just pass a specific image to the Aspose.OCR Cloud API, and it will return a response with recognized text.

It is easy to get started with Aspose.OCR Cloud, and there is nothing to install. Create an account at Aspose Cloud and get your application information, then you are ready to use SDKs

  • API version: 21.2.0
  • Package version: 21.2.0

OCR Processing Features

  • Recognize and extract text from images via OCR.
  • Specify the area of the image from which you want to extract text.
  • Perform OCR to recognize text from the whole or partial image.
  • Fetch character and font information from raster images.
  • Return the response in the JSON or XML format.
  • Supports English text recognition.

Save OCR As

TXT, PDF, HOCR

Read OCR Formats

BMP, JPG, GIF, PNG, TIFF

How to use the SDK?

Our API is completely independent of your operating system, database system, or development language. You can use any language and platform that supports HTTP to interact with our API. However, manually writing client code can be difficult, error-prone, and time-consuming. Therefore, we have provided and support SDKs in many development languages to make it easier to integrate with us.

Prerequisites

To use Aspose OCR for Cloud Node.js SDK you need to register an account with Aspose Cloud and lookup/create App Key and SID at Cloud Dashboard. There is a free quota available. For more details, see Aspose Cloud Pricing.

Installation

npm

npm install @asposecloud/aspose-ocr-cloud --save

git

Install it via:

    npm install https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-nodejs --save

Getting Started

  1. Sign Up. Before you begin, you need to sign up for an account on our Dashboard and retrieve your credentials.
  2. Minimum requirements. This SDK requires Node.js 6.x and higher.
  3. Install Aspose.OCR Cloud Node.js SDK.

Please, add the following nmp package to your project.json as a dependency.

{
  "dependencies": {
    "@asposecloud/aspose-ocr-cloud":"^21.2.0"
  }
}

Please follow the installation instruction and execute the following JS code:

NOTE: Use the helper from /test/helper.js for an upload and save data.

    // Get keys from aspose site.
    // There is free quota available. 
    // For more details, see https://purchase.aspose.cloud/pricing
	
var conf = {
    "basePath":"https://api.aspose.cloud/v3.0",
    "authPath":"https://api.aspose.cloud/connect/token",
    "apiKey":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "appSID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    
};

//Create storage api for upload to server
var fs = require('fs');
var path = require('path');
var instance = new Asposeocrcloud.OcrApi(conf);

var buffer = Buffer.alloc(1024 * 50);
var fileData = fs.readFileSync(YOUR_FILE_PATH, buffer);

instance.RecognizeFromContentAuto(fileData, function (err, data, res) {
    console.log(data);
});
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your package from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('@asposecloud/aspose-ocr-cloud') in javascript files from the directory you ran the last command above from.

Install For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the OCR pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

OCR from URL in Node.Js

	// Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
	var conf = {
		"apiKey":"MY_CLIENT_SECRET",
		"appSID":"MY_CLIENT_ID",
		"basePath":"https://api.aspose.cloud/v3.0",
		"authPath":"https://api.aspose.cloud/connect/token"
	};
	
	const ocrApi = new Asposeocrcloud.OcrApi(conf);

	var imageUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png";
	ocrApi.RecognizeFromUrlAuto(imageUrl, function (err, data, res) {
		console.log(data);
	});

Documentation for API Endpoints

DEMO Application contain various examples of using the Aspose.OCR SDK NodeJS.

Detailed API Reference is avalable at /docs/ folder.

OCR API

Image formats suported: .bmp, .dib .jpeg, .jpg, .jpe .jp2 .png .webp .pbm, .pgm, .ppm .pxm, .pnm .pfm .sr, .ras .tiff, .tif .exr .hdr, .pic

Aspose.OCR Cloud SDKs in Popular Languages

.NET Java Python Android NodeJS
GitHub GitHub GitHub GitHub GitHub
NuGet Maven PIP Maven NPM

Product Page | Documentation | API Reference | Code Samples | Blog | Free Support | Free Trial

About

Aspose OCR Cloud NodeJS SDK is a simple OCR technology, which you can use in your application to convert image to text.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published