如何在JSPDF中防止表格在多个页面上分裂 [英] How to prevent spliting of Table over mutliple pages in jspdf

查看:156
本文介绍了如何在JSPDF中防止表格在多个页面上分裂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jspdf生成我的pdf报告.我有多个表来说明原理,但是当我生成pdf时,表的行在不同的页面之间分割,第一页的上一行在后面的几页中.

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.

推荐答案

您必须在添加新内容之前始终检查实际页面大小

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");

来源: MrRio/jsPDF/issues/101

这篇关于如何在JSPDF中防止表格在多个页面上分裂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆