Miramac/node-office-script

PPT opens every time and Flashs on screen for a while

Closed this issue · 3 comments

I am using a sych version but i have to read a bunch of PPT file and all the files opens once and flash on screen for a while that creates a problem.
Is there any solution to avoid it?

can you give some sample code? I've used it with max. 3 parallel open PPT files, but it should be able to handle more.

var PPTList = ["PPT1.pptx",PPT2.pptx, "PPT3.pptx", "PPT4.pptx", "PPT5.pptx", "PPT6.pptx"];

`for (var ppt = 0; ppt < PPTList.length; ppt++){
openPresentation(PPTList[ppt]);
}

function openPresentation(presentationName){
try {
presentation = new Presentation(path.join(__dirname, presentationName));
var slides = presentation.slides();
console.log('Slide count: ', slides.length);
presentation.saveAs({name: path.join(__dirname, presentationName+'.pdf'), type: 'pdf'});
}
catch (e) {
console.error(e)
}
if (presentation) {
presentation.quit() // Close presentation & quit application
}
}`

try to use close and quit the application only on the end.

var PPTList = ["PPT1.pptx",PPT2.pptx, "PPT3.pptx", "PPT4.pptx", "PPT5.pptx", "PPT6.pptx"];
var presentation
var slides
for (var ppt = 0; ppt < PPTList.length; ppt++){
    presentation = new Presentation(path.join(__dirname, PPTList[ppt]));
    slides = presentation.slides();
    console.log('Slide count: ', slides.length);
    presentation.saveAs({name: path.join(__dirname, PPTList[ppt]+'.pdf'), type: 'pdf'});
    presentation.close() // Close presentation
}
if (presentation) {
    presentation.quit() // quit application
}