I am trying to add images in ppt file using pptxGenjs in angular5.
I am able to get the file with content, but I want to get the ppt file data in base64 or any other output format, but I am getting only the filename in data.
const pptx = new pptGen();
const slide = pptx.addNewSlide();
// slide.addImage({ data: 'image/png;base64, ' + b64Data + '', x: 1, y: 2, w: 3, h: 3 })
slide.addImage({ path: '/assets/mean.jpg', x: 1, y: 2, w: 3, h: 3 })
slide.addText('Image Path!', { x: 1.5, y: 1.5, font_size: 18, color: '363636' });
pptx.save('jszip', this.getData, 'base64');
// pptx.save('http', this.getData); // I tried this also
getData = () => {
console.log(data);
}
How to get the stream of ppt file data? It would very helpful If I get any help on this.
I resolved my problem by making some changes in the library. the changes which I made is:
File: pptxgen.js
go to line no 1823 and replace the code:
// original code
zip.generateAsync({type:'blob'}).then(function(content){ writeFileToBrowser(strExportName, content); });
// code to replace
zip.generateAsync({type:'blob'})
.then(function(content){
gObjPptx.saveCallback(content);
// writeFileToBrowser(strExportName, content);
});