Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

587
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda