我正在使用jsPDF Autotable生成包含多个表的pdf文档。 function generate(){
var doc = new jsPDF('l', 'pt', 'a3');
var res = doc.autoTableHtmlToJson(document.getElementById('predicts'));
doc.autoTable(res.columns, res.data,{
styles: { overflow: 'linebreak', columnWidth: 65 }
});
var res2 = doc.autoTableHtmlToJson(document.getElementById('EMPPredict'));
doc.autoTable(res2.columns, res2.data, {
startY: doc.autoTableEndPosY() + 10,
styles: { overflow: 'linebreak', columnWidth: 65 },
});
var res3 = doc.autoTableHtmlToJson(document.getElementById('Nonepredict'));
doc.autoTable(res3.columns, res3.data, {
startY: doc.autoTableEndPosY() + 10,
styles: { overflow: 'linebreak', columnWidth: 65 }
});
var res4 = doc.autoTableHtmlToJson(document.getElementById('E2EPredict'));
doc.autoTable(res4.columns, res4.data, {
startY: doc.autoTableEndPosY() + 10,
styles: { overflow: 'linebreak', columnWidth: 65 }
});
我试图找出如何为每个表添加标题而没有任何成功。
我可以在顶部和页脚添加标题,但有没有办法在每个表格上方添加标题?
提前致谢 doc.save(" EOD_Results.pdf&#34);
答案 0 :(得分:1)
您可以根据需要在页面上的任何位置添加内容。您可以看一下此示例,例如:https://simonbengtsson.github.io/jsPDF-AutoTable/#long
doc.text(7, 15, "Overflow 'ellipsize' (default)");
doc.autoTable(columnsLong, getData(), {
startY: 20,
margin: {horizontal: 7},
styles: {columnWidth: 'wrap'},
columnStyles: {text: {columnWidth: 'auto'}}
});
doc.text("Overflow 'hidden'", 7, doc.autoTable.previous.finalY + 10);
doc.autoTable(columnsLong, getData(), {
startY: doc.autoTable.previous.finalY + 15,
margin: {horizontal: 7},
styles: {overflow: 'hidden', columnWidth: 'wrap'},
columnStyles: {text: {columnWidth: 'auto'}}
});