title: How to serve base64-pdf for download from nodejs-server?
body: <p>I generate a PDF and get a string like <code>data:application/pdf;base64,JVBERi0xLjMKJf////8K...</code> .. I save this in a MongoDB. </p>
  
  <p>Now I need to deliver this as a pdf-download to the client. So, I get the entry from the DB and try:</p>
  
  <pre><code>res.writeHead(200, {'Content-Type': 'application/pdf'});
  res.end(base64String); // base64String is the data:application/pdf;base64,JVB..-string
  </code></pre>
  
  <p>This opens a empty pdf in the browser and displays a error:</p>
  
  <blockquote>
    <p>Error loading the PDF document</p>
  </blockquote>
  
  <p>how can get this working? Do I need to prepare the base64String in some way before sending it to the client?</p>