Skip to content

Commit

Permalink
Merge pull request #41 from ellisgl/master
Browse files Browse the repository at this point in the history
Call back for save method (nodejs only)
  • Loading branch information
gitbrent authored Feb 16, 2017
2 parents ea25632 + 1ff7f4e commit 10256be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dist/pptxgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var PptxGenJS = function(){
/**
* Export the .pptx file (using saveAs - dep. filesaver.js)
*/
function doExportPresentation() {
function doExportPresentation(callback) {
var intSlideNum = 0, intRels = 0;

// STEP 1: Create new JSZip file
Expand Down Expand Up @@ -171,7 +171,7 @@ var PptxGenJS = function(){
// STEP 3: Push the PPTX file to browser
var strExportName = ((gObjPptx.fileName.toLowerCase().indexOf('.ppt') > -1) ? gObjPptx.fileName : gObjPptx.fileName+gObjPptx.fileExtn);
if ( NODEJS ) {
zip.generateAsync({type:'nodebuffer'}).then(function(content){ fs.writeFile(strExportName, content); });
zip.generateAsync({type:'nodebuffer'}).then(function(content){ fs.writeFile(strExportName, content, callback); });
}
else {
zip.generateAsync({type:'blob'}).then(function(content){ saveAs(content, strExportName); });
Expand Down Expand Up @@ -1761,7 +1761,7 @@ var PptxGenJS = function(){
* Export the Presentation to an .pptx file
* @param {string} [inStrExportName] - Filename to use for the export
*/
this.save = function save(inStrExportName) {
this.save = function save(inStrExportName, callback) {
var intRels = 0, arrRelsDone = [];

// STEP 1: Set export title (if any)
Expand All @@ -1780,7 +1780,7 @@ var PptxGenJS = function(){
});

// STEP 3: Export now if there's no images to encode (otherwise, last async imgConvert call above will call exportFile)
if ( intRels == 0 ) doExportPresentation();
if ( intRels == 0 ) doExportPresentation(callback);
};

/**
Expand Down

0 comments on commit 10256be

Please sign in to comment.