title: Puppeteer pdf page break bug
body: <p>I try to generate pdf file by puppetter. It works good for one page but when I try to generate multipage pdf document, I have a bug with page breaks. HTML template is used for generate below. Please, help me if you can. Pre condition for reproduce: fill first page on 100% height and add title for block below.</p>
  <p>HTML template</p>
  <pre><code>function getHTMLTemplate(
      height = 'auto', 
      component = '&lt;div&gt;&lt;/div&gt;', 
      style = '&lt;style&gt;&lt;/style&gt;',
      header = '&lt;div&gt;&lt;/div&gt;',
      footer = '&lt;div&gt;&lt;/div&gt;',
  ) {
      return `
          &lt;!DOCTYPE html&gt;
          &lt;html&gt;                
              &lt;head&gt;
                  &lt;meta charset=&quot;utf-8&quot; /&gt;
                  &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
                  &lt;title&gt;HTML to PDF Example&lt;/title&gt;
                  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
                  &lt;style&gt;
                      * {margin: 0; padding: 0; border-spacing: 0;}
  
                      .page {
                          width: 210mm;
                          height: ${height};
                          overflow: hidden;
                          background: transparent;
                          margin-top: -1px !important;
                          margin-bottom: -1px !important;
                      }
  
                      body&gt;div {
                          width: 100%;
                          position: fixed;
                      }
  
                      body&gt;div:first-child {
                          top: 0;
                      }
  
                      body&gt;div:nth-child(2) {
                          bottom: 0;
                      }
                      
                      @page {
                          size: 'A4';
                          margin: 0;
                      }
                      
                      @media print {
                          thead {display: table-header-group;} 
                          tfoot {display: table-footer-group;}
  
                          html, body {
                              width: 210mm;
                              height: 297mm;
                          }
                          
                          tbody::after {
                              content: ''; 
                              display: block;
                              page-break-after: always;
                              page-break-inside: avoid;
                              page-break-before: avoid;        
                          }
                      }
  
                      .block {
                          top: 0;
                          width: 210mm;
                          height: 40px;
                          position: absolute;
                          background: #092a4e;
                          z-index: 1;
                      }
                  &lt;/style&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;div class=&quot;block&quot;&gt;&lt;/div&gt;
                  ${header}
                  ${footer}
                  &lt;table&gt;
                      &lt;thead&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  ${header}
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  &lt;div class=&quot;page&quot;&gt;
                                      ${component}
                                      ${style}
                                  &lt;/div&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/tbody&gt;
                      &lt;tfoot&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  ${footer}
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/tfoot&gt;
                  &lt;/table&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      `;
  }
  </code></pre>
  <p>Generate PDF</p>
  <pre><code>const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
  const page = await browser.newPage();
  await page.emulateMediaType('print');
  await page.setContent(utils.getHTMLTemplate(`calc(891mm - 82px)`, component, sheet.getStyleTags(), template.header, template.footer));
  const buffer = await page.pdf({
     format: &quot;A4&quot;,
     margin: { top: 0, bottom: 0, right: 0, left: 0 },
     printBackground: true,
  });
  </code></pre>
  <p>Bug
  <a href="https://i.stack.imgur.com/Bjf6T.png" rel="noreferrer">enter image description here</a></p>