user3172435
user3172435

Reputation: 25

How to prevent spliting of Table over mutliple pages in jspdf

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.enter image description here

Upvotes: 0

Views: 2711

Answers (1)

Arpit Goyal
Arpit Goyal

Reputation: 1005

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

Upvotes: 1

Related Questions