Generating and serving pdf file


#1

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

On the server

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

On the client

Meteor.call '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 ?


#2

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