gpt4 book ai didi

javascript - 在autotable之前添加div内容

转载 作者:行者123 更新时间:2023-12-03 01:00:05 25 4
gpt4 key购买 nike

我正在使用这些插件**1)jspdf.plugin.autotable.js2) jspdf.debug.js **

我使用以下代码

var pdf = new jsPDF("p", "pt");
pdf.fromHTML($("#otherdivcontent").get(0), 70, 300, {
width: 500
});
var res = pdf.autoTableHtmlToJson(document.getElementById("table2"));

pdf.autoTable(res.columns, res.data);

pdf.autoPrint();

pdf.save("Report.pdf");

脚本

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript" src="jspdf.debug.js"></script>
<script type="text/javascript" src="jspdf.plugin.autotable.js"></script>

这是生成的pdf generated pdf

我想将两个内容合并为一个 pdf...并且我想要表格之前的 div 内容...请帮助我调整对齐方式。我想要第二页的表格......我该如何解决这个问题..

最佳答案

这是解决方案,

pdf.fromHTML($("#test1").get(0), 30,100, {
'width': margins.width
},
margins);
pdf.autoTable(data.columns, data.rows,
{margin: {top: 80,bottom:50},
startY:h+20,
tableWidth: 500,
styles: {
overflow: 'linebreak',
columnWidth: 'wrap',
// rowHeight:'wra',
lineWidth: 1
}});

“h”是 div #test1 的高度。

关于javascript - 在autotable之前添加div内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52664675/

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