diff --git a/lib/aspose-pdf.js b/lib/aspose-pdf.js index eaee53a..7c4eb14 100644 --- a/lib/aspose-pdf.js +++ b/lib/aspose-pdf.js @@ -39,6 +39,29 @@ AsposePdf.prototype.getAttachmentsCount = function(fileName,pageNumber,callback) }); }; +AsposePdf.prototype.getAttachments = function(fileName,pageNumber,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : 1; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/attachments'; + 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.Attachments); + } else { + throw new Error(data.Message); + } + } + }); +}; + AsposePdf.prototype.getAttachment = function(fileName,pageNumber,attachmentIndex,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -107,6 +130,29 @@ AsposePdf.prototype.getBookmarksCount = function(fileName,pageNumber,callback){ }); }; +AsposePdf.prototype.getBookmarks = function(fileName,pageNumber,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : 1; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/bookmarks'; + 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.Bookmarks); + } else { + throw new Error(data.Message); + } + } + }); +}; + AsposePdf.prototype.getChildBookmarksCount = function(fileName,parentBookmark,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -203,6 +249,29 @@ AsposePdf.prototype.getAnnotationsCount = function(fileName,pageNumber,callback) }); }; +AsposePdf.prototype.getAnnotations = function(fileName,pageNumber,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : 1; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/annotations'; + 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.Annotations); + } else { + throw new Error(data.Message); + } + } + }); +}; + AsposePdf.prototype.getAnnotation = function(fileName,pageNumber,annotationIndex,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -275,6 +344,29 @@ AsposePdf.prototype.getLinksCount = function(fileName,pageNumber,callback){ }); }; +AsposePdf.prototype.getLinks = function(fileName,pageNumber,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : 1; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/links'; + 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.Links); + } else { + throw new Error(data.Message); + } + } + }); +}; + /* Text Editing Methods */ AsposePdf.prototype.replaceText = function(fileName,oldText,newText,regularExpression,pageNumber,callback){ @@ -328,6 +420,49 @@ AsposePdf.prototype.replaceText = function(fileName,oldText,newText,regularExpre }); }; +AsposePdf.prototype.replaceMultipleText = function(fileName,postData,pageNumber,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + postData = typeof postData !== 'undefined' ? postData : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : 0; + + if(fileName === ''){ + throw new Error('Filename not defined.'); + } + + if(postData === 0){ + throw new Error('postData not defined.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName; + + if(pageNumber > 0){ + strURI = strURI + '/pages/' + pageNumber + '/replaceTextList'; + } else { + strURI = strURI + '/replaceTextList'; + } + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + var appSID = this.appSID; + var appKey = this.appKey; + var baseURI = this.baseURI; + + Utils.ProcessCommand('POST',signedURI,postData,function(data){ + var asposeStorage = new AsposeStorage({'appSID':appSID,'appKey':appKey,'baseURI':baseURI}); + if(data.Status === 'OK'){ + asposeStorage.getFile(fileName, '', function(data){ + + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); + } else { + throw new Error(data.Message); + } + }); +}; + AsposePdf.prototype.getTextFormat = function(fileName,pageNumber,fragmentNumber,segmentNumber,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -346,12 +481,17 @@ AsposePdf.prototype.getTextFormat = function(fileName,pageNumber,fragmentNumber, if(fragmentNumber === 0){ throw new Error('fragment number not defined.'); } + - if(segmentNumber === 0){ - throw new Error('segment number not defined.'); - } - - var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/fragments/' + fragmentNumber + '/segments/' + segmentNumber + '/textformat'; + var strURI = this.baseURI + 'pdf/' + fileName + '/pages/' + pageNumber + '/fragments/' + fragmentNumber; + if(fragmentNumber > 0) + { + strURI = strURI + '/segments/' + segmentNumber + '/textformat'; + } + else + { + strURI = strURI + '/textformat'; + } var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); Utils.ProcessCommand('GET',signedURI,'',function(data){ @@ -612,6 +752,29 @@ AsposePdf.prototype.convert = function(fileName,imageFormat,callback){ }); }; +AsposePdf.prototype.convertByUrl = function(url,saveFormat,callback){ + url = typeof url !== 'undefined' ? url : ''; + saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : ''; + + if(url === ''){ + throw new Error('url not defined.'); + } + + if(saveFormat === ''){ + throw new Error('saveFormat missing.'); + } + + + var strURI = this.baseURI + 'pdf/convert?url=' + url + '&format='+saveFormat; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommandContent('PUT',signedURI,'',function(data){ + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); +}; + AsposePdf.prototype.convertToImage = function(fileName,pageNumber,imageFormat,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : ''; @@ -1109,6 +1272,43 @@ AsposePdf.prototype.getFormFields = function(fileName,callback){ }); }; +AsposePdf.prototype.updateFormField = function(fileName,fieldName,fieldType,fieldValue,callback){ + fileName = typeof fileName !== 'undefined' ? fileName : ''; + fieldName = typeof fieldName !== 'undefined' ? fieldName : ''; + fieldType = typeof fieldType !== 'undefined' ? fieldType : ''; + fieldValue = typeof fieldValue !== 'undefined' ? fieldValue : ''; + + if(fileName === ''){ + throw new Error('filename not provided.'); + } + + if(fieldName === ''){ + throw new Error('fieldName not provided.'); + } + + if(fieldType === ''){ + throw new Error('fieldType not provided.'); + } + + if(fieldValue === ''){ + throw new Error('fieldValue not provided.'); + } + + var strURI = this.baseURI + 'pdf/' + fileName + '/fields/' + fieldName; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + var json_data = {'Name':fieldName, 'Type':fieldType, 'Values':[fieldValue]}; + + Utils.ProcessCommand('PUT',signedURI,json_data,function(data){ + if(typeof callback === 'function'){ + + if(data.Status === 'OK'){ + callback.call(null,data.Field); + } + } + }); +}; + AsposePdf.prototype.getFormFieldCount = function(fileName,callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -1304,7 +1504,6 @@ AsposePdf.prototype.createFromTiff = function(pdfFilename,tiffFilename,callback) }; - AsposePdf.prototype.mergeDocuments = function(sourceFiles,targetFile,callback){ sourceFiles = typeof sourceFiles !== 'undefined' ? sourceFiles : ''; targetFile = typeof targetFile !== 'undefined' ? targetFile : ''; @@ -1396,4 +1595,84 @@ AsposePdf.prototype.getPageCount = function(fileName,callback){ }); }; +AsposePdf.prototype.addSignature = function(pdfFilename,pageNumber,postData,callback){ + pdfFilename = typeof pdfFilename !== 'undefined' ? pdfFilename : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : ''; + postData = typeof postData !== 'undefined' ? postData : ''; + + if(pdfFilename === ''){ + throw new Error('pdf filename not provided.'); + } + + if(postData === ''){ + throw new Error('postData not provided.'); + } + + var strURI = this.baseURI + 'pdf/' + pdfFilename; + if(pageNumber != '') + { + strURI = strURI + '/pages/' + pageNumber; + } + strURI = strURI + '/sign'; + + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + var appSID = this.appSID; + var appKey = this.appKey; + var baseURI = this.baseURI; + + Utils.ProcessCommand('POST',signedURI,postData,function(data){ + var asposeStorage = new AsposeStorage({'appSID':appSID,'appKey':appKey,'baseURI':baseURI}); + if(data.Status === 'OK'){ + asposeStorage.getFile(pdfFilename, '', function(data){ + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); + } else { + throw new Error(data.Status); + } + }); + +}; + +AsposePdf.prototype.addStamp = function(pdfFilename,pageNumber,postData,callback){ + pdfFilename = typeof pdfFilename !== 'undefined' ? pdfFilename : ''; + pageNumber = typeof pageNumber !== 'undefined' ? pageNumber : ''; + postData = typeof postData !== 'undefined' ? postData : ''; + + if(pdfFilename === ''){ + throw new Error('pdf filename not provided.'); + } + + if(pageNumber === ''){ + throw new Error('pageNumber not provided.'); + } + + if(postData === ''){ + throw new Error('postData not provided.'); + } + + var strURI = this.baseURI + 'pdf/' + pdfFilename + '/pages/' + pageNumber + '/stamp'; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + var appSID = this.appSID; + var appKey = this.appKey; + var baseURI = this.baseURI; + + Utils.ProcessCommand('PUT',signedURI,postData,function(data){ + var asposeStorage = new AsposeStorage({'appSID':appSID,'appKey':appKey,'baseURI':baseURI}); + if(data.Status === 'OK'){ + asposeStorage.getFile(pdfFilename, '', function(data){ + if(typeof callback === 'function'){ + callback.call(null,data); + } + }); + } else { + throw new Error(data.Status); + } + }); + +}; + module.exports = AsposePdf; diff --git a/package.json b/package.json index a01b240..52d406d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asposecloud", - "version": "1.6.0", + "version": "1.7.0", "description": "Aspose Cloud SDK for NodeJS", "main": "lib/aspose-cloud.js", "scripts": {