If you're deploying your app to somewhere where you can't be sure to have reliable disk read/write access, the normal strategy of writing to a temp-file doesn't work.
Instead we can open a pipe to the Phantom.js process, and then pass in the HTML via stdin
, and then have the rasterize.js
script write out the resulting PDF to stdout
, which we can then capture.
Any log messages from the Phantom.js process can be passed via stderr
if we want.
If we're using the default Rails setup for session handling, i.e. a _session_id
cookie, we can just pass in the session ID and have the rasterize.js
script fake a session cookie.
We can provide some additional configuration for the Phantom.js process using a config.json
file.
(I can't remember exactly why we set the things as we did, but some of them were needed.)
Hi @fercreek
Sorry for the late response. I don't think I get notifications on comments on gists, so haven't seen this before now.
How you attach a file in an email depends very much on the libraries you're using. But if we're talking ActionMailer, I would think you should be able to do something like:
See also https://api.rubyonrails.org/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Attachments