title: Full page PDF in Puppeteer
body: <p>I am trying to get a full page PDF using <code>puppeteer</code> and my code is like this,
  But the resultant is multiple pages with the height equal to that of the page.</p>
  
  <p>How do i resolve this? TIA.</p>
  
  <pre><code>const puppeteer = require("puppeteer");
  
  function sleep(ms) {
      return new Promise(resolve =&gt; {
          setTimeout(resolve, ms);
      });
  }
  
  (async () =&gt; {
      const browser = await puppeteer.launch({
          headless: true
      });
  
      const page = await browser.newPage();
  
      await page.goto("http://localhost:3000/longpage", {
          waitUntil: "networkidle2"
      });
  
      let height = await page.evaluate(
          () =&gt; document.documentElement.offsetHeight
      );
  
      console.log("Height", height);
  
      await page.pdf({
          path: "hni.pdf",
          printBackground: true,
          margin: "none",
          height: height + "px"
      });
  
      await browser.close();
  })();
  </code></pre>