title: How to get pdf buffer from response body with puppeteer?
body: <p>I need to download a pdf while it navigates to &quot;chrome pdf view&quot; with puppeteer.
  <a href="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" rel="nofollow noreferrer">this</a> is the test link I have been using to test this.</p>
  <p>I am trying to get the pdf buffer from the response body</p>
  <pre><code>page.on('response', async response =&gt; {
    console.log('in response');
    if (response.url().includes('.pdf')) {
      console.log(await response.text())
    }
  
  })
  await page.goto('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf')
  </code></pre>
  <p>but only gives me the preview data of the pdf</p>
  <blockquote>
  <p>&lt;!doctype html&gt;&lt;embed name='1FE75881C67175A5ACEE8BB8FF5B3136' style='po
  sition:absolute; left: 0; top: 0;'width='100%' height='100%' src='about:blank' type='application/pdf' internalid='1FE75881C67175A5ACEE8BB8FF5B3136'&gt;</p>
  </blockquote>
  <p>I also tried response.buffer() but this also gives me the preview data. But I need the buffer for the actual pdf file data.</p>
  <p>When I hit the pdf link in postman I do see the pdf data in body so I can't figure out why I can't get that in puppeteer response.</p>
  <p><a href="https://i.stack.imgur.com/YxJ9e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YxJ9e.png" alt="here is postman response" /></a></p>