gpt4 book ai didi

javascript - 错误: ArrayBuffer is undefined

转载 作者:行者123 更新时间:2023-11-28 06:12:06 24 4
gpt4 key购买 nike

我正在使用 html2canvas 和 jsPDF 将 div 导出为 PDF,正在 Google Chrome、Firefox 和 IE 11 上运行,但在 IE 9 和 10 版本中出现错误:ArrayBuffer 未定义。

代码:

function exportPDF(relatorio){

var form = $(relatorio);

var cache_width = form.width();

var a4 =[ 595.28, 841.89];

getCanvas(form).then(function(canvas){

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

var imgWidth = 210;

var pageHeight = 295;

var imgHeight = canvas.height * imgWidth / canvas.width;

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(form){
//CONVERT for canvas
return html2canvas(form,{
imageTimeout:2000,
removeContainer:true
});
}

最佳答案

看看这个链接: http://caniuse.com/#feat=typedarrays

它会告诉您 ArrayBuffer 在 Internet Explorer 9 中不受支持,只有在 Internet Explorer 10 中才受警告支持。这意味着您必须修改代码才能使用其他内容(例如此处的 polyfill:https://github.com/inexorabletash/polyfill/blob/master/typedarray.js )或者您将不得不忍受您的代码无法在 IE 9 和/或 10 中运行。

关于javascript - 错误: ArrayBuffer is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36285249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com