我正在尝试使用自动表并排显示两个表的信息。当我没有那么多条目并且信息仅需要一页时,它会显示正常。但是,当我有大量数据和多个页面时,直到第一个表显示了其大部分条目后,第二个表才开始显示。
这是一个带有示例数据的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();
Simon Bengts.. 7
您必须在绘制表格之间手动设置页面。我用工作代码更新了小提琴,但是基本上可以这样完成:
var startingPage = doc.internal.getCurrentPageInfo().pageNumber; doc.autoTable({html: '#table', margin: {right: 305}}); doc.setPage(startingPage); doc.autoTable({html: '#table', margin: {left: 305}});
还要签出多个表示例,以包括跨多个表的水平表。
您必须在绘制表格之间手动设置页面。我用工作代码更新了小提琴,但是基本上可以这样完成:
var startingPage = doc.internal.getCurrentPageInfo().pageNumber; doc.autoTable({html: '#table', margin: {right: 305}}); doc.setPage(startingPage); doc.autoTable({html: '#table', margin: {left: 305}});
还要签出多个表示例,以包括跨多个表的水平表。