请检查链接 https://jsfiddle.net/dhaileytaha/1wmk9gsq/14/
<script>
/*Download option*/
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
doc.fromHTML($('#example').html(), 55, 55, {
'width': 170,
'elementHandlers': specialElementHandlers
});
document.getElementById("cmd").onclick = function () {
var pass1= "cool" ;
password=prompt('Please enter your password to Print this page!',' ');
if (password==pass1)
{
doc.save('target-file.pdf');
} else {
window.alert('Sorry! You are not Authorsised');
}
}
</script>
这是一个数据表。我能够以正确的格式打印它,但无法以与数据表相同的格式下载。 请帮忙 我想要与 pdf 形式的数据表相同的格式。
最佳答案
您使用的 jspdf 资源可能是旧资源,无法正常工作。
您应该做的另一件事是用 div 标签包装内容。
我用以下版本尝试了你的 fiddle 示例,它有效。 http://mrrio.github.io/jsPDF/dist/jspdf.debug.js
关于javascript - 下载的pdf格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36279272/