How to prevent spliting of Table over mutliple pages in jspdf

断了今生、忘了曾经 提交于 2021-02-05 11:38:18

问题


I am using jspdf for generating my pdf report. I have multiple tables which show the principle, but when I am generating the pdf, table's rows are splitting between different pages, the upper row in initial page and later in later page.

I want the full table in a single page if there is no enough space in one page move the whole table in next page.


回答1:


you have to check the actual page size always before adding new content

doc = new jsPdf();
...
pageHeight= doc.internal.pageSize.height;

// Before adding new content
y = 500 // Height position of new content
if (y >= pageHeight)
{
  doc.addPage();
  y = 0 // Restart height position
}
doc.text(x, y, "value");

Source: MrRio/jsPDF/issues/101



来源:https://stackoverflow.com/questions/35179026/how-to-prevent-spliting-of-table-over-mutliple-pages-in-jspdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!