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": {