title: Base64 to Pdf export issue AWS Lambda
body: <p>I'm creating pdf document using AWS Lambda Puppeteer Nodejs package.</p>
  
  <pre><code>const page = await browser.newPage()
  page.setContent(html)
  
  const pdf = await page.pdf({
    format: 'A4',
    printBackground: true,
    margin: { top: '1cm', right: '1cm', bottom: '1cm', left: '1cm' }
  })
  
  var pdf_base64 = await pdf.toString('base64');
  
  const response = {
   headers: {
     'Content-Type': 'application/pdf',
     'Content-Disposition': 'attachment;filename=downloaded.pdf'
    },
   statusCode: 200,
   body: pdf_base64,
   isBase64Encoded: true
  }
  </code></pre>
  
  <p>Pdf is getting downloaded but seems corrupted or not properly encoded. 
  While opening chrome shows <code>Failed to load PDF document.</code></p>
  
  <p>But, if i remove headers and export the base 64 &amp; save it to pdf using any online service proper pdf is generated and working. </p>
  
  <p>Even if i open downloaded pdf using text-editor and copy the base64 content and re-generated pdf from base64 using any online tool it works. </p>
  
  <p>What can be the issue while returning.</p>