I have a Rails app where I use wicked_pdf to generate PDF's. This is all fine and working locally, but when pushed to heroku the PDF does render, but without applying the stylesheet.
Especially for PDF rendering I have a CSS file: app/assets/stylesheets/pdf.css.scss
. And in form.pdf.haml
I load the stylesheet like this:
!!!
%html{lang: "en", "xml:lang" => "en", xmlns: "http://www.w3.org/1999/xhtml"}
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
= wicked_pdf_stylesheet_link_tag "pdf"
As said, it works great locally, but when pushed to heroku, I get this error:
ActionView::Template::Error (No such file or directory - /app/public/pdf.css)
What do I have to do to make this work on heroku?
Edit: I found this Gihub repo https://github.com/jordan-brough/heroku-pdf
, which is an example app for using wicked_pdf on heroku. It really helped by adapting the environment.rb
to serve a css file from the public
folder when requesting a PDF.