Having some trouble applying CSS to Grover, a tool I'm using to render and download PDF copies of documents generated in my app. While the CSS renders as expected in Grover's debug mode (rendered in Chromium), it seems that my application.css is not being applied when downloaded as a PDF in headless mode.
The method used to generate the PDF is within a concern:
def purchase_order_gen(the_purchase_order, request_host_with_port)
puts "generating pdf"
puts "Generating PDF for PO " + the_purchase_order.id.to_s
puts "Host is " + request_host_with_port
html = render_to_string({
partial: '/purchase_orders/display_purchase_order',
layout: '/layouts/pdf_layout.html.erb',
locals: { po: the_purchase_order }
})
puts "html";
ap html
the_display_url = 'http://' + request_host_with_port
grover = Grover.new(html, {format: 'A4' , display_url: the_display_url})
pdf = grover.to_pdf
puts "Back From Grover!"
return pdf
end
To reference the CSS, I've placed the following line in the <head>
of my layout:
<%= stylesheet_link_tag '/assets/stylesheets/application.css'%>
It seems like there may be an issue with the stylesheet_link_tag
, possibly related to the asset pipeline where the debug version is able to access but the headless version is not pulling from.