title: Generate pdf file using pdfkit and send it to browser in nodejs-expressjs
body: <p>I am using pdfkit to generate pdf file and i want to send this pdf file to browser.
  <br/>
  <br/>
  But i am getting message  <code>"TypeError: listener must be a function",</code>
  Also, file is getting generate in my parent directory which i don't want.
  <br/>
  <br/>
  <strong>Can anyone explain me how to generate pdf file and send it to browser without storing it at parent directory?</strong>
  <br/>
  I am using expressjs here.</p>
  
  <h3>My code</h3>
  
  <pre><code>var PDFDocument = require('pdfkit');                      
  var fs=require('fs');
  doc = new PDFDocument();
  doc.moveTo(300, 75)
     .lineTo(373, 301)
     .lineTo(181, 161)
     .lineTo(419, 161)
     .lineTo(227, 301)
     .fill('red', 'even-odd');  
  
  var loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in...';  
  
  doc.y = 320;
  doc.fillColor('black')
  doc.text(loremIpsum, {
     paragraphGap: 10,
     indent: 20,
     align: 'justify',
     columns: 2
  });  
  
  doc.write('out.pdf');
  res.download('out.pdf');
  </code></pre>