I am currently working on a Rails application that utilizes wicked_pdf for generating PDF files. Everything works perfectly fine when testing locally, but once the app is deployed to Heroku, the generated PDF does not apply the stylesheet.
Specifically for PDF rendering, I have a CSS file located at:
app/assets/stylesheets/pdf.css.scss
. In my form.pdf.haml
file, I include the stylesheet in the following way:
!!!
%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"
Despite working without any issues locally, deploying to Heroku results in the following error message:
ActionView::Template::Error (No such file or directory - /app/public/pdf.css)
Is there anything specific that needs to be done in order to rectify this issue on Heroku?
Edit: I came across a helpful Github repository
https://github.com/jordan-brough/heroku-pdf
, which provides an example application for utilizing wicked_pdf on Heroku. By adjusting the environment.rb
to serve a css file from the public
folder when requesting a PDF, it greatly assisted in resolving the problem.