title: Dynamic check if text Goes to next page and add pagebreak in pdf using pdfmake
body: <p>For a project im making offer and invoice pdf's on the fly using pdfmake in javascript. The problem im facing is having text blocks going off the page in the middle. What i want is to check if a certain block of text or a table is going to be split between pages and if so add a pagebreak before the block to make sure the text or table will be entirely on one page. </p>
  
  <p>My pdf docDefinition is build like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>return {
                  content: [
                      getOfferLogo(), //Get the logo or empty string
                      getHeading(), //get the customer and business data (adress etc)
                      //the above is always the same
                      getText(), //get the textblock, created by user and always different
                      getSpecifics(), //get a table of payment specifications
                      getSignature() //get last textblock contaning signature fields etc, always the same
                  ],
                  styles: {
                      subheader: {
                          fontSize: 15,
                          bold: true,
                          alignment: 'center'
                      }
                  },
                  defaultStyle: {
                      columnGap: 20,
                      fontSize: 12
                  }
              };</code></pre>
  </div>
  </div>
  </p>
  
  <p>So in short how can i check if text will be going off the page before creating the pdf and add pagebreaks accordingly?</p>
  
  <p>Thanks in advance.</p>