我正在尝试使用Autotable并排显示两个表的信息。当我没有那么多条目并且信息只需要一页时,它显示正常。但是,当我有大量数据和多个页面时,第二个表在第一个表显示大部分条目之前不会开始显示。
这是一个JsFiddle,其中包含用于说明问题的示例数据。我尝试更改第二个表的y位置,但它似乎只是在显示的页面上移动数据并切断数据的顶部而不是将其移动到之前的页面上。
function generatePdf() {
header = ["Reason","Duration","Start time"];
content = [
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"],
["Analyzer blowback","10h15m","08:04"]
];
var doc = new jsPDF('p', 'pt');
doc.autoTable(header, content, {
showHeader: 'firstPage',
styles: { fontSize: 10 },
avoidPageSplit: true,
margin: { right: 305 }
});
doc.autoTable(header, content, {
showHeader: 'firstPage',
styles: { fontSize: 10 },
avoidPageSplit: true,
margin: { left: 305 }
});
doc.save("test.pdf")
}
generatePdf();
答案 0 :(得分:5)
您必须在绘制表格之间手动设置页面。我使用工作代码更新了您的fiddle,但基本上可以这样做:
var startingPage = doc.internal.getCurrentPageInfo().pageNumber;
doc.autoTable(header, content, {margin: {right: 305}});
doc.setPage(startingPage);
doc.autoTable(header, content, {margin: {left: 305}});
同时检查multiple tables example以包含跨越多个表的水平表。