title: Create a PDF from HTML and send it to the user from a buffer
body: <p>I'm trying to generate a PDF from an HTML file from the frontend and the users may download the PDF (never be stored on the server).</p>
  
  <p>For this I am using the module: <strong>html5-to-pdf</strong></p>
  
  <p>My code is like this:</p>
  
  <pre><code>var pdf = require('html5-to-pdf');
  var fs = require('fs');
  
  router.post('/pdf', function(req, res) {
    var html = req.body.html;
  
    if (!html) {
      return res.sendStatus(400);
    }
  
    pdf().from.string(html).to.buffer({
      renderDelay: 1000
    }, function(err, data) {
      if (err) {
        return res.sendStatus(500);
      }
  
      var file = fs.createWriteStream('myDocument.pdf');
      file.write(data, function(err) {
        if (err) {
          res.sendStatus(500);
        }
  
        res.download('myDocument');
      });
    });
  
  });
  </code></pre>
  
  <p>Whenever I download a file size of 0Bytes and also creates the file on the server</p>
  
  <p>Someone could help me?</p>