开发者

How can I write a css file from a database to a file for use with PDFKit?

开发者 https://www.devze.com 2023-02-11 19:13 出处:网络
To add a stylesheet to a pdf rendering using PDFKit, I use: kit = PDFKit.new(\"html goes here\") kit.stylesheets << \"path/to/css\"

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消