pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Forcing page breaking a table at a specific row

Open LuisPinaSoares opened this issue 6 years ago • 3 comments

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;
    }
  },

pdfmake

LuisPinaSoares avatar Jul 05 '20 10:07 LuisPinaSoares

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!!!

alexjesjimalex avatar Jul 15 '20 18:07 alexjesjimalex

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

betko avatar Aug 13 '20 08:08 betko

duplicate: https://github.com/bpampuch/pdfmake/issues/994

liborm85 avatar Feb 07 '26 16:02 liborm85