Error : Arraybuffer is Undefined

Asked

Viewed 57 times

0

Good morning everyone, I’m using html2canvas and jsPDF to export a div for PDF, is working on Google Chrome, firefox and IE 11, but in versions 9 and 10 of IE is being displayed the 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
    }); 
}

1 answer

1


How can you check in compatibility tables, in Internet Explorer 9 and earlier, ArrayBuffer just doesn’t exist. On the 10, you shouldn’t be getting this mistake.

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 it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.