Error: ArrayBuffer is undefined

0

Good morning everyone, I'm using html2canvas and jsPDF to export a div to PDF, it works in Google Chrome, firefox and IE 11, but in versions 9 and 10 IE is being displayed following message:

Error

  

ArrayBuffer is undefined

CODE:

//função js que gera o PDF
function gerarPDF(relatorio)
{

     //atribuo meu relatorio a VARIAVEL form
     var form = $(relatorio);

     //crio a variavel da largura do meu relatorio
     var cache_width = form.width();

    //crio a variavel com a LARGURA & ALTURA de uma pagina A4
     var a4  =[ 595.28,  841.89];  

     //chamo a função get canvas que tira o print da minha tela
     getCanvas(form).then(function(canvas){

         var imgData = canvas.toDataURL('image/png');

         //largura da IMG
         var imgWidth = 210; 


         //altura da pagina
         var pageHeight = 295;  


         //altura da imagem é igual a altura do canvas * largura da imagem / pela largura do canvas
         var imgHeight = canvas.height * imgWidth / canvas.width;

         //tamanho restante = altura da imagem
         var heightLeft = imgHeight;

         var doc = new jsPDF('p', 'mm');

         var position = 0;

         doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);

         heightLeft -= pageHeight;

         while (heightLeft >= 0) {

           position = heightLeft - imgHeight;

           doc.addPage();

           doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);

           heightLeft -= pageHeight;

         }

         doc.save('relatorioOrcadoRealizado.pdf');
         form.width(cache_width);


     });
}

function getCanvas(divExportada){
 //CONVERTE a divExportada PARA CANVAS
 return html2canvas(divExportada,{
     imageTimeout:2000,
     removeContainer:true
    }); 
}
    
asked by anonymous 29.03.2016 / 15:02

1 answer

1

As you can check in compatibility tables in Internet Explorer 9 and earlier , ArrayBuffer simply does not exist. By the 10th, you should not be getting this error.

If you have problems with archaic versions of browsers, always check the compatibility of the features you are using. The Can I Use is very good for this.

    
01.04.2016 / 13:40