gpt4 book ai didi

javascript - 需要帮助让 jspdf 将 html 渲染为 PDF

转载 作者:行者123 更新时间:2023-11-28 04:56:00 25 4
gpt4 key购买 nike

我正在尝试让 jspdf 工作。单击我的 fiddle 中的按钮后什么也没有发生。这是jsfiddle (https://jsfiddle.net/light22/68h81owf/)。预先感谢您对我的帮助。

这是我正在使用的脚本:

<script>
function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'letter');

source = $('#for_pdf')[0];

specialElementHandlers = {

'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};

pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},

function (dispose) {

pdf.save('download.pdf');
}, margins
);
}
</script>

最佳答案

点击 jsfiddle 中的按钮后,抛出错误:ReferenceError: demoFromHTML is not defined 。您还忘记关闭<table>中的样式属性

关于javascript - 需要帮助让 jspdf 将 html 渲染为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42549436/

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