From 560aaa8b183cfca88b787137803059e41c905ee2 Mon Sep 17 00:00:00 2001 From: Assad Mahmood Date: Wed, 27 May 2015 16:09:27 +0500 Subject: [PATCH] Implementation of Missing Features in Aspose.Barcode Create Barcode on Aspose Cloud Storage Generate Barcode with Appropriate Code Text Location Generate Barcode with Checksum Option Rotate Barcode Image with Suitable Angle Set Barcode Image Height, Width and Quality along with Auto Size Option Set Barcode Image Margin Set Barcode Image Resolution Set Height of the Bars in the Barcode Image Set X and Y Dimensions of a Barcode Read Barcodes by Applying Image Processing Algorithm --- lib/aspose-barcode.js | 61 +++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/lib/aspose-barcode.js b/lib/aspose-barcode.js index b772ee5..8ec1fe9 100644 --- a/lib/aspose-barcode.js +++ b/lib/aspose-barcode.js @@ -1,6 +1,7 @@ var Utils = require('./utils'); var path = require('path'); var fs = require('fs'); +var qs = require('querystring'); var AsposeStorage = require('./aspose-storage'); function AsposeBarcode(config) { @@ -11,16 +12,19 @@ function AsposeBarcode(config) { /* Creation Methods */ -AsposeBarcode.prototype.save = function(codeText,symbology,imageFormat,callback){ +AsposeBarcode.prototype.save = function(codeText,symbology,imageFormat,options,callback){ codeText = typeof codeText !== 'undefined' ? codeText : ''; symbology = typeof symbology !== 'undefined' ? symbology : 'QR'; imageFormat = typeof imageFormat !== 'undefined' ? imageFormat : 'png'; + options = typeof options !== 'undefined' ? options : ''; if(codeText === ''){ throw new Error('Code text not provided.'); } - var strURI = this.baseURI + 'barcode/generate?text=' + codeText + '&type=' + symbology + '&format=' + imageFormat; + var extra_qry_str = qs.stringify(options); + + var strURI = this.baseURI + 'barcode/generate?text=' + codeText + '&type=' + symbology + '&format=' + imageFormat + '&' + extra_qry_str; var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); Utils.ProcessCommandContent('GET',signedURI,'',function(data){ @@ -32,6 +36,32 @@ AsposeBarcode.prototype.save = function(codeText,symbology,imageFormat,callback) }; +AsposeBarcode.prototype.save_in_cloud = function(codeText,symbology,fileName,options,callback){ + codeText = typeof codeText !== 'undefined' ? codeText : ''; + symbology = typeof symbology !== 'undefined' ? symbology : 'QR'; + fileName = typeof fileName !== 'undefined' ? fileName : ''; + options = typeof options !== 'undefined' ? options : ''; + + if(codeText === '' || fileName === ''){ + throw new Error('Required parameters missing.'); + } + + var extra_qry_str = qs.stringify(options); + + var strURI = this.baseURI + 'barcode/' + fileName + '/generate?text=' + codeText + '&type=' + symbology + '&' + extra_qry_str; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + console.log(signedURI); + + Utils.ProcessCommand('PUT',signedURI,'',function(data){ + + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); + +}; + + /* Reader Methods */ AsposeBarcode.prototype.readLocal = function(fileStream,symbology,callback){ @@ -129,6 +159,33 @@ AsposeBarcode.prototype.read = function(fileName,symbology,callback){ }; +AsposeBarcode.prototype.readByAlgorithm = function(fileName,algo,callback){ + fileName = typeof fileName !== 'undefined' ? fileName : ''; + algo = typeof algo !== 'undefined' ? algo : ''; + + if(fileName === '' || algo === ''){ + throw new Error('Missing required parameters.'); + } + + var strURI = this.baseURI + 'barcode/' + fileName + '/recognize'; + if(algo != ''){ + strURI = strURI + '?BinarizationHints=' + algo; + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('GET',signedURI,'',function(data){ + if(typeof callback === 'function'){ + if(data.Status === 'OK'){ + callback.call(null,data.Barcodes); + } else { + throw new Error(data.Message); + } + } + }); + +}; + AsposeBarcode.prototype.readRegion = function(fileName,symbology,x,y,w,h,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; symbology = typeof symbology !== 'undefined' ? symbology : ''; diff --git a/package.json b/package.json index eac9f89..a3e1bbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asposecloud", - "version": "1.4.0", + "version": "1.5.0", "description": "Aspose Cloud SDK for NodeJS", "main": "lib/aspose-cloud.js", "scripts": {