我有一个带有表格和图形的div,需要导出为PDF,我使用html2canvas.js创建一个画布并使用jsPDF.js在pdf文档中添加画布并且它有效!但仅在Mozilla Fire Fox和谷歌Chrome中,Internet Explorer 9,10和11无效!有人知道是否可以在IE中执行此操作或是否存在不兼容问题?
CODE:
function createPDF(relatorio){
//获取报告标签 var form = $(relatorio);
Ana,31
Edgar,16
Luis,22
Noelia,26
Isabel50
Pablo,34
Laura,18
Paco,17
}
//为CANVAS转换DIV
function getCanvas(form){
返回html2canvas(表单,{
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);
}