Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

585
Views
Pdfmake keep two rows together on page break when to page break on table

For the pdfmake, I have a table in which it uses two rows per record. Ex: enter image description here and when the table breaks it breaks by each row. However, I want it to break after or before 2 rows in a table, which you keep the two rows together in one page.

Instead of : enter image description here

I want the two rows to be in the same page. Is there a way to make sure this happens? I've tried to use the pageBreakBefore function, however I'm not that intuitive with it and there haven't been any good examples online.

var dd = {
        content: [
    
        'The following table has nothing more than a body array',
        {
            style: 'tableExample',
            table: {
               dontBreakRows:true,
              //  headerRows:1,
                body: [
                    [{text:'Col', colSpan:3, fillColor:'grey'}, {},{}],
                    [{text:'Column 1',fillColor:'blue'}, {text:'Column 2',fillColor:'blue'}, {text:'Column 3',fillColor:'blue'}],
                    ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}],
                                        ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}]
,
                    ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}]
,                   ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}]
,                   ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}]
,                   ['One value goes here', 'Another one here', 'OK?'],
                    [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}]
,


                ],
            }
        },
    ]
    
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You could define these rows as separate tables, each in one row in root table. This way, rows won't be separated because they will be in one row in top-level table

about 4 years ago · Juan Pablo Isaza Report

0

You can handle it like this:

pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
  //Here you can change the criteria of pageBreak according to your requirement
  if (currentNode.id === 'myid' && (currentNode.pageNumbers.length != 1 || currentNode.pageNumbers[0] != currentNode.pages)) {
    return true;
  }
  //Here you can change the criteria of pageBreak according to your requirement
  else if (currentNode.id === 'mySecondid' && currentNode.pageNumbers.length != 1) {
    return true;
  }
  return false;
},
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!