diff --git a/lib/aspose-slides.js b/lib/aspose-slides.js index 4426703..09e3deb 100644 --- a/lib/aspose-slides.js +++ b/lib/aspose-slides.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 AsposeSlides(config) { @@ -647,6 +648,56 @@ AsposeSlides.prototype.convert = function(fileName,saveFormat,folderName,storage }); }; +AsposeSlides.prototype.convertWithAdditionalSettings = function(fileName,saveFormat,settings,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : 'pdf'; + settings = typeof settings !== 'undefined' ? settings : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + + var strURI = this.baseURI + 'slides/' + fileName; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + + if( strURI.search('\\?') > 0 ){ + strURI = strURI + '&format=' + saveFormat; + }else{ + strURI = strURI + '?format=' + saveFormat; + } + + strURI = strURI + qs.stringify(settings); + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommandContent('GET',signedURI,'',function(data){ + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); +}; + AsposeSlides.prototype.convertLocalFile = function(fileStream,saveFormat,callback){ fileStream = typeof fileStream !== 'undefined' ? fileStream : ''; saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : ''; @@ -846,6 +897,288 @@ AsposeSlides.prototype.saveSlideAs = function(fileName,saveFormat,slideNumber,fo }); }; +AsposeSlides.prototype.mergePresentations = function(fileName,mergeList,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'slides/' + fileName + '/merge'; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + var post_data = JSON.stringify(mergeList); + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('PUT',signedURI,post_data,function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data.Document); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.splitPresentations = function(fileName,fromSlide,toSlide,destination,saveFormat,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + fromSlide = typeof fromSlide !== 'undefined' ? fromSlide : ''; + toSlide = typeof toSlide !== 'undefined' ? toSlide : ''; + destination = typeof destination !== 'undefined' ? destination : ''; + saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === '' || fromSlide === '' || toSlide === '' ){ + throw new Error('missing required parameters.'); + } + + var strURI = this.baseURI + 'slides/' + fileName + '/split'; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + strURI = strURI + qs.stringify({'from':fromSlide,'to':toSlide,'destFolder':destination,'format':saveFormat}); + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,'',function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.addSlide = function(fileName,position,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === '' ){ + throw new Error('missing required parameters.'); + } + + var strURI = this.baseURI + 'slides/' + fileName + '/slides'; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + if( strURI.search('\\?') > 0 ){ + strURI = strURI + '&position=' + position; + }else{ + strURI = strURI + '?position=' + position; + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,'',function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.cloneSlide = function(fileName,slideNo,position,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + slideNo = typeof slideNo !== 'undefined' ? slideNo : ''; + position = typeof position !== 'undefined' ? position : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === '' || slideNo === '' || position === ''){ + throw new Error('missing required parameters.'); + } + + var strURI = this.baseURI + 'slides/' + fileName + '/slides'; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + if( strURI.search('\\?') > 0 ){ + strURI = strURI + '&position=' + position + '&SlideToClone=' + slideNo; + }else{ + strURI = strURI + '?position=' + position + '&SlideToClone=' + slideNo; + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,'',function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.changeSlidePosition = function(fileName,oldPosition,newPosition,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + oldPosition = typeof oldPosition !== 'undefined' ? oldPosition : ''; + newPosition = typeof newPosition !== 'undefined' ? newPosition : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === '' || oldPosition === '' || newPosition === ''){ + throw new Error('missing required parameters.'); + } + + var strURI = this.baseURI + 'slides/' + fileName + '/slides'; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + if( strURI.search('\\?') > 0 ){ + strURI = strURI + '&oldPosition=' + oldPosition + '&newPosition=' + newPosition; + }else{ + strURI = strURI + '?oldPosition=' + oldPosition + '&newPosition=' + newPosition; + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,'',function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.createEmptyPresentation = function(fileName,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'slides/' + fileName; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('PUT',signedURI,'',function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data.Document); + } else { + throw new Error(data.Status); + } + } + }); +}; + AsposeSlides.prototype.saveAs = function(fileName,saveFormat,folderName,storageName,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -1330,4 +1663,92 @@ AsposeSlides.prototype.getSlideCount = function(fileName,folderName,storageName, }); }; +AsposeSlides.prototype.getAspectRatio = function(fileName,slideNumber,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + slideNumber = typeof slideNumber !== 'undefined' ? slideNumber : 1; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + + var strURI = this.baseURI + 'slides/' + fileName + '/slides/' + slideNumber ; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + 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.Slide.Width / data.Slide.Height); + } else { + throw new Error(data.Status); + } + } + }); +}; + +AsposeSlides.prototype.getComments = function(fileName,slideNumber,folderName,storageName,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + slideNumber = typeof slideNumber !== 'undefined' ? slideNumber : 1; + folderName = typeof folderName !== 'undefined' ? folderName : ''; + storageName = typeof storageName !== 'undefined' ? storageName : ''; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + + var strURI = this.baseURI + 'slides/' + fileName + '/slides/' + slideNumber ; + + if(folderName !== '' || storageName !== ''){ + strURI = strURI + '?'; + + if(folderName !== ''){ + strURI = strURI + 'folder=' + folderName; + } + + if(storageName !== ''){ + if( folderName !== '' ){ + strURI = strURI + '&storage=' + storageName; + } + else{ + strURI = strURI + 'storage=' + storageName; + } + } + } + + 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.SlideComments); + } else { + throw new Error(data.Status); + } + } + }); +}; + module.exports = AsposeSlides; diff --git a/package.json b/package.json index a3e1bbe..a01b240 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asposecloud", - "version": "1.5.0", + "version": "1.6.0", "description": "Aspose Cloud SDK for NodeJS", "main": "lib/aspose-cloud.js", "scripts": {