PptxGenjs writeFile() not working in IE11

729 Views Asked by At

While everything seems to work fine, when debugger hits pres.writeFile() function , i cant get the pptx at all. Mostly like a promise-base issue. Of course when testing with Chrome everything works as expetexted. Anyone face any similar issue before? Any suggestions? What's wrong with IE11?

    var pres = new pptxgen();

function fetch_data(el) {
    $.ajax({
        url:`${document.querySelector('.off-to-see-the-wizard > .route').innerHTML}`,
        contentType:"application/json",
        dataType:"json",
        success:function(response){
            if(response)
            {                 
                var data=JSON.parse(response);
                createPresentation(data,el);
            }
            else{
                console.log(response)
            }
        },
        error:function(err){
            console.log(err);
        }
    })
}


function createPresentation(data){
    var second_image="image/base64 ...."
    var main_image="image/jpg;base64 ..."

    function createMasterSlide(pres){
        pres.defineSlideMaster({
                title:'MASTER_SLIDE',
                bkgd:  'FFFFFF',
                objects:[
                    {'text':{text:`Test ${data._gateDescript} review`,options:{color:'000000',x:4.7,y:6.77,h:0.46,w:3.63, fontSize:14}}},
                    {'image':{x:0.3,y:6.47,w:1.14,h:0.83,data:second_image}}
                ],
                slideNumber: { x:9.11, y:6.77 ,w:0.43 ,h:0.42}
            })
        }
    function createMainSlide(pres){
        pres.author="Team";
        pres.layout='LAYOUT_4x3';
        let main_slide=pres.addSlide();
        main_slide.addImage({data:main_image, w:10, h:7.5})
        main_slide.addText(`Project ID:  ${data._p.Id}\nProject Name: ${data._p.Name}`, {color:'D55C00' ,x:0.47, y:3.56, w:5.0, h:0.7, fontSize:24})
        main_slide.addText(`Review: Test ${data._gateDescript} \nDate: ${Date.now()} `)
        }

    createMasterSlide(pres);
    createMainSlide(pres);
    pres.writeFile('Presentation.pptx');
}

Quick Update Error : Please see image attached. Error

Ι get to know that jszip has an issue with ie11 To be specific pptxgenjs make use of jszip , that runs generateInternalStream. In the scope of this function something breaks out. Any clues?

2

There are 2 best solutions below

0
On BEST ANSWER

Quick update for your reference . The issue was finally resolved by installing jszip 3.1.5 version. Its stable and functionally using IE11.

So you should install this specific version

npm install [email protected] --save

Then please navigate to node modules , get to copy all jszip node module. Navigate back to pptxgenjs node module. Navigate into pptxgenjs--->node_modules and overwrite jszip with the version you have installed and copied previously.

So pptxgenjs lib would use jszip 3.1.5 version .

Issue resolved. Thanks everyone :)

3
On

Which version of jszip are you using? It seems that [email protected] uses jszip v3.2.1 for default.

I found some have the same error when using jszip version 3.2.x in IE and Edge. You could refer to this thread. The last version not having this problem is 3.1.5. You could try with jszip version 3.1.x.