Meteor 1.3 + Blaze + SSR + wkhtmltopdf

In the app I have created in 1.2 I use SSR to generate Templates from which I can then render data into the pdf gen app, wkhtmltopdf. It works great with few issues.

Alas the problems arise from the fact that I am now trying to make this work in Meteor 1.3, with Blaze and although still early days in my trials, I am hitting a buffer.

From what I can see there may be 1/2/3 solutions, though maybe someone can add insight or their own solution:

  1. Use React and build the downloads/documents solution in FlowRouter with SSR with React. Certainly not the end of the world, but not my preferred choice at this point.

  2. Maybe push the templates into package which may well then be imported, and accessible server side. Yet to try this option.

  3. Hack together some node/fibers/fs solution to read HTML from the files (assuming they can be compiled in as assets) and pump them into the imported Templates/Blaze objects.

Any other thoughts/ideas/solutions are welcome.

I know Galaxy has SSR within the service, so this is either coming to Meteor 1.3 (i hope) or I need to sign up for Galaxy (not my hope)

Thanks in advance!

V -

Current solution, for which I have success is to:

  1. setup a package with html files applied to server using api.addAssets, which forces meteor to build the HTML files into the ./assets/packages/<pkg_name> directory of the cwd()

  2. this then allows me to read them using fs.readFile, and with a new Future() to be able to read the files asynchronously.

  3. with the content of the file I am able to use meteorhacks:ssr to perform SSR.compileTemplate( , );

  4. this then allows me to do SSR.render(, { …data… }); into wkhtmltopdf

I doubt this would scale up but works for the low request environment in which this iit s being used currently.

Hopefully a better solution in due course, when time permits or requires. Though I just had the thought that perhaps calling a config and running through the templates and calling SSR.compileTemplate on server startup may push the load to the front end and only require calls to the filesystem “once”.