I want to use GROVER to export same ERB/HTML pages from my application as PDF. It works, but the generated PDF seems to be missing the styles and formatting, no CSS seems to be processed.
Here my code within the controller:
html_string = render_to_string(
{
template: 'users/show.html.erb',
locals: { id: params[:id] }
})
pdf = Grover.new(html_string, format: 'A4').to_pdf
respond_to do |format|
format.html
format.pdf do
send_data(pdf, disposition: 'inline', filename: "Show_ID_#{params[:id]}", type: 'application/pdf')
end
end
My question is, how I can persuade GROVER also to process the CSS files ?
I had the same problem where my layout was rendered without the CSS. I was able to resolve the issue by adding the
display_urloption in Grover.In local development this would be for example:
You need to change your
display_urldepending on your environment.If this does not work, make sure the
html_stringthat you are rendering actually includes the correct markup. You can render out thehtml_stringas HTML to verify all markup is included.