title: How to print full page of SPA to pdf using NodeJS and Puppeteer correctly?
body: <p>Please help me to generate the pdf file from the page of react single-page application with client-side rendering.
  I have implement the client app with button "Save as pdf" and server-side endpoint with puppeteer code (see below).
  When I click "Save as pdf" I want to see the pdf file with full current page, but I see only first page with only visible content.
  Where is error in my code?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>const express = require("express");
  const morgan = require("morgan");
  const cors = require("cors");
  const puppeteer = require("puppeteer");
  
  const app = express();
  const PORT = process.env.PORT || 3005;
  
  const printPdf = async (projectId, reportName) =&gt; {
    const browser = await puppeteer.launch({
      headless: true
    });
  
    const page = await browser.newPage();
  
    page.setViewport({
      width: 1920,
      height: 1080
    });
  
    page.goto(
      `http://localhost:3000/project/${projectId}/report/${reportName}`,
      { waitUntil: "networkidle2" }
    );
  
    await page.waitForNavigation();
    await page.type("#username", process.env.USERNAME);
    await page.type("#password", process.env.PASSWORD);
    await page.click("#submit");
    await page.waitForSelector(".content", { visible: true });
  
    const pdfFile = await page.pdf({
      format: "A4",
      printBackground: true
    });
  
    await browser.close();
  
    return pdfFile;
  };
  
  app.use(cors());
  app.use(morgan("combined"));
  
  app.get("/export", function(req, res) {
    const { projectId, reportName } = req.query;
  
    printPdf(projectId, reportName)
      .then(pdf =&gt; {
        res.set({
          "Content-Type": "application/pdf",
          "Content-Length": pdf.length
        });
  
        res.send(pdf);
      })
      .catch(error =&gt; {
        console.log("!!ERROR", error);
      });
  });
  
  app.listen(PORT, () =&gt; {
    console.log("Server running on port %d", PORT);
  });
  </code></pre>