[英]Export DIV to PDF don't work in Internet Explorer
我有一個帶表格和圖形的div,需要導出為PDF,我使用html2canvas.js創建一個畫布並使用jsPDF.js在pdf文檔中添加畫布並且它有效! 但僅在Mozilla Fire Fox和谷歌Chrome中,Internet Explorer 9,10和11無效! 有人知道是否可以在IE中執行此操作,還是存在不兼容問題?
碼:
function createPDF(relatorio){
//獲取報表chice var form = $(relatorio);
var cache_width = form.width();
//A4 SIZE
var a4 =[ 595.28, 841.89];
//CALL THE GET CANVAS FUNCTION
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);
}
// CONVERT DIV FOR CANVAS
function getCanvas(form){
return html2canvas(form,{
imageTimeout:2000,
removeContainer:true
});
}
經過同里搜索的,我已經找到了一個解決這個問題,我需要使用填充工具來提供一個arrayBuffer的小姐IE9。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.