title: How can I handle puppeteer to save pdf from a print dialog?
body: <p>I have a print button and on clicking it, sends some request and opens up the print dialog. Now this is not coming directly from a URL and is not easy to decode.</p>
  
  <p>Example print dialog</p>
  
  <p><a href="https://i.stack.imgur.com/xBeke.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xBeke.png" alt="Example print dialog"></a></p>
  
  <p>Is there a way I can save this document as pdf using puppeteer?</p>
  
  <p>Existing Code:</p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  (async () =&gt; {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.setViewport({width: 1440, height: 2000});
    await page.goto(`https://www.southwest.com/air/check-in/review.html?confirmationNumber=${process.argv[2]}&amp;passengerFirstName=${process.argv[3]}&amp;passengerLastName=${process.argv[4]}`, {
      waitUntil: 'networkidle2'
    });
    [ confirmationNumber, checkinButtonText ] = [ await page.$eval('.confirmation-number--code', el =&gt; el.innerHTML), await page.$eval('.actionable_primary.actionable_large-button', el =&gt; el.innerHTML) ]
    console.log(checkinButtonText);
    console.log(confirmationNumber);
    await page.click('.actionable_primary.actionable_large-button');
    // The below line makes a click on the button
    await page.click('.air-check-in-boarding-pass-options .boarding-pass-options--button-email, .air-check-in-boarding-pass-options .boarding-pass-options--button-print, .air-check-in-boarding-pass-options .boarding-pass-options--button-text');
    await browser.close();
  
  })();
  </code></pre>