Forcing page breaking a table at a specific row
Hi,
Any suggestions are welcome I have searched on github and in other places but haven't been able to find this specific case solved.
I have main rows that have under them a few children rows, how can i break all this rows together to the next page, if a set of (main row + children rows) are split between pages, like in the image presented.
I have tried using ids on the main row, and if the current main row is in one page and the next main row is in the next page i just force a page break before the current main row (this is a bit brute force logic, but was mainly to test pageBreakBefore property).
Something like this:
pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
if(currentNode.id) {
// console.log('***************');
// console.log(currentNode);
// console.log(followingNodesOnPage);
// console.log(nodesOnNextPage);
// console.log(previousNodesOnPage);
for (let i=1; i < followingNodesOnPage.length; i++) {
if (followingNodesOnPage[i].id) {
return false;
}
}
return true;
}
},

i use a style for that like this: tableHeader: { bold: true, fontSize: 6, color: 'black', pageBreak: 'before' } but before in the table i put this: table: { widths: [120, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], headerRows: 1, } try it!!!
For me the solution for this issue was the dontBreakRows: true property of the table.
In your case I think you have to set this to the main table.
Please check: https://github.com/bpampuch/pdfmake/issues/8
duplicate: https://github.com/bpampuch/pdfmake/issues/994