Skip to content

Commit

Permalink
PDF Creation Feature from JPEG SVG and TIFF Files
Browse files Browse the repository at this point in the history
  • Loading branch information
assadvirgo committed Dec 31, 2014
1 parent 9317de1 commit 7dc84b1
Showing 1 changed file with 104 additions and 1 deletion.
105 changes: 104 additions & 1 deletion lib/aspose-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,109 @@ AsposePdf.prototype.createFromHtml = function(pdfFilename,htmlFilename,callback)

};

AsposePdf.prototype.createFromJpeg = function(pdfFilename,jpegFilename,callback){
pdfFilename = typeof pdfFilename !== 'undefined' ? pdfFilename : '';
jpegFilename = typeof jpegFilename !== 'undefined' ? jpegFilename : '';

if(pdfFilename === ''){
throw new Error('pdf filename not provided.');
}

if(jpegFilename === ''){
throw new Error('jpeg filename not provided.');
}

var strURI = this.baseURI + 'pdf/' + pdfFilename + '?templateFile=' + jpegFilename + '&templateType=jpeg';
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,'',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.createFromSvg = function(pdfFilename,svgFilename,callback){
pdfFilename = typeof pdfFilename !== 'undefined' ? pdfFilename : '';
svgFilename = typeof svgFilename !== 'undefined' ? svgFilename : '';

if(pdfFilename === ''){
throw new Error('pdf filename not provided.');
}

if(svgFilename === ''){
throw new Error('svg filename not provided.');
}

var strURI = this.baseURI + 'pdf/' + pdfFilename + '?templateFile=' + svgFilename + '&templateType=svg';
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,'',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.createFromTiff = function(pdfFilename,tiffFilename,callback){
pdfFilename = typeof pdfFilename !== 'undefined' ? pdfFilename : '';
tiffFilename = typeof tiffFilename !== 'undefined' ? tiffFilename : '';

if(pdfFilename === ''){
throw new Error('pdf filename not provided.');
}

if(tiffFilename === ''){
throw new Error('tiff filename not provided.');
}

var strURI = this.baseURI + 'pdf/' + pdfFilename + '?templateFile=' + tiffFilename + '&templateType=tiff';
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,'',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.mergeDocuments = function(sourceFiles,targetFile,callback){
sourceFiles = typeof sourceFiles !== 'undefined' ? sourceFiles : '';
targetFile = typeof targetFile !== 'undefined' ? targetFile : '';
Expand Down Expand Up @@ -1293,4 +1396,4 @@ AsposePdf.prototype.getPageCount = function(fileName,callback){
});
};

module.exports = AsposePdf;
module.exports = AsposePdf;

0 comments on commit 7dc84b1

Please sign in to comment.