To add a stylesheet to a pdf rendering using PDFKit, I use:
kit = PDFKit.new("html goes here")
kit.stylesheets << "path/to/css"
But I am on heroku and I need a way to be able to change the stylesheet from the web interface. So I am cr开发者_JS百科eating a field to store it in the database, for example, letter.css would store the css.
How can that value be turned (I assume) into a temp file so that I can use the stylesheets method for PDFKit object?
You can save the css contents into a file in the tmp subdirectory and include it from there - Heroku allows write access to that directory.
精彩评论