ppt-template icon indicating copy to clipboard operation
ppt-template copied to clipboard

Dynamically changing the PPTX File and cloning

Open navaswd opened this issue 6 years ago • 1 comments

can you please tell me how to call second return function from this code?

files.forEach(function(fileId) {
                module.exports.fileDet(res, fileId, function(res, fileData) {
                    fileDetArr.push(fileData);
 fileDetails.forEach(function(data) {


                                //console.log("data.fileName===", data.fileName);
                                // return false;

                                var originalfileName = parentDir + '\\uploads\\' + data.fileName + ".pptx";
                                var output_fileName = docTitle + '_' + fileName + '.pptx';
                                var output_fileDirectory = parentDir + '\\uploads\\' + output_fileName;

                                var Presentation = PPT_Template.Presentation;
                                var Slide = PPT_Template.Slide;

                                // Presentation Object
                                var myPresentation = new Presentation();

                                // Load example.pptx
                                myPresentation.loadFile(originalfileName)

                                .then(() => {
                                    console.log("originalfileName==", originalfileName);
                                    page_number = (data.pageNumber) + 1;
                                    let cloneSlide = myPresentation.getSlide(page_number).clone();
                                    sampleArray.push(cloneSlide);



                                    // console.log("1--------", myPresentation.generate(sampleArray));
                                    // if (sampleArray.length == fileDetails.length) {
                                    console.log("1--------", myPresentation.generate(sampleArray));
                                    return myPresentation.generate(sampleArray);

                                    // }

                                })

                            })

                            .then(() => {

                                console.log("2--------", newPresentation);
                                return newPresentation;


                            })

                            // Output .pptx file
                            .then(() => {

                                return newPresentation.saveAs(output_fileDirectory);

                            })

                            .then(() => {

                                console.log('- Save Successfully');
                              

                            })
})
})
})

navaswd avatar Apr 11 '18 10:04 navaswd

can you change the function without then function?

navaswd avatar Apr 11 '18 11:04 navaswd