Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call back for save method (nodejs only) #41

Merged
merged 1 commit into from
Feb 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1712,7 +1712,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 @@ -1731,7 +1731,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