title: Blob from buffer returns corrupted pdf
body: <p>Trying to make a pdf with Puppeteer on Firebase Functions: send in html snippet, get a pdf back.</p>
  <p>But the pdf is corrupted. The problem is, I think, with returning the file / buffer.</p>
  <pre class="lang-js prettyprint-override"><code>// Server:
  
  // setup
  const func = require('firebase-functions');
  const pptr = require('puppeteer');
  const opts = { memory: '1GB', regions: ['europe-west3'] };
  const call = func.runWith(opts).https.onCall
  let browser = pptr.launch({ args: ['--no-sandbox'] });
  
  // onCall
  exports.makePdf = call(async (data) =&gt; {
    // this works, does open the page testing with { headless: false }
    const brws = await (await browser).createIncognitoBrowserContext();
    const page = await brws.newPage();    
    await page.setContent(data, { waitUntil: 'domcontentloaded' });
    const file = await page.pdf({ format: 'A4' });
    await brws.close();
    // the problem is returning the file
    return file
  });
  
  </code></pre>
  <p>When <code>file</code> is logged on the server it's a buffer <code>&lt;Buffer 25 50 44 46 2d 31 2e ... 11150 more bytes&gt;</code>, but when logged on the client it's an object, in dec and not hex <code>{ data: {0: 37, 1: 80, 2: 68, 3: 70, ... }}</code>.</p>
  <p>Convert that back to buffer? Convert back to hex? Which buffer?</p>
  <pre class="lang-js prettyprint-override"><code>// Client:
  
  // send html and receive the file
  let html = '&lt;div&gt;&lt;h1&gt;Hi&lt;/h1&gt;&lt;/div&gt;';
  let file = ((await fns.makePdf(html))).data;
  // also tried buffer = new Buffer.from(JSON.stringify(file));
  let blob = new Blob(file, { type: 'application/pdf' });
  
  // download the file
  let a = document.createElement('a');
  a.href = window.URL.createObjectURL(blob);
  a.download = `${name}.pdf`;
  a.click();
  </code></pre>
  <p>Or is the pdf corrupted because I'm downloading it wrong (<code>createObjectURL</code>)? Or onCall functions can't be used this way?</p>
  <p>Point is, don't know why it's not working. Thanks for your help</p>