Generating and serving pdf file


I am using node-html-pdf in my application which works awesome. I have something like

On the server

  generatePDF: (html, filename) ->
    options =
      filename: '/home/Files/pdfs/' + filename + '.pdf'
      phantomPath: "/home/Apps/phantomjs/bin/phantomjs"
    pdf.create(html, options).toFile (err, res) ->

On the client 'generatePDF', html, 'meteor.pdf'

And this works like a charm, but now I wonder how can I serve this file to the client, also It would be awesome if the server method returns the file to the client automatically ? Is that possible ?


see this other pdf question - Which package do you use to generate PDFs in Meteor?

basically you can use iron-router with a server side method to stream the result back to the user - i’m using phantom/webshot to generate a pdf of my app, but the streaming/sending part should be the same for you