mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.53k stars 644 forks source link

PDF doesn't show same thing as debug #513

Closed javimbk closed 8 years ago

javimbk commented 8 years ago

I have some troubles displaying a page full of charts built with C3.js with WickedPDF.

Here are the differences between the PDF and show_as_html: params.key?('debug'):

Graph 1 PDF vs. Graph 1 Debug (This one's weird because you can almost see it on the PDF) Graph 2 PDF vs. Graph 2 Debug Graph 3 PDF vs. Graph 3 Debug

I already tried increasing javascript_delayto a huge number but that doesn't do anything. It's not a matter of Wicked not having enough time to display the charts.

Also, I've included the correct wicked_pdf_stylesheet_link_tag and wicked_pdf_javascript_include_tag , otherwise the charts on debug wouldn't be showing correctly.

I would appreciate the help, I can't think of any other way to debug this other than using the debug function and a lot of tries I've already done. On debug everything works correctly.

unixmonkey commented 8 years ago

javascript_delay tells wkhtmltopdf to wait x milliseconds before executing any javascript (to make sure all the HTML fully rendered?).

You might have more luck with no_stop_slow_scripts: true, or perhaps specifying (in CSS) the width of the viewport (since it looks like things are being shrunk).

Let me know how it goes!

baramik commented 8 years ago

@unixmonkey javascript_delay this option seems to be working. I was facing the same issue with highcharts. Hope this will help somebody. Thanks

javimbk commented 8 years ago

@unixmonkey , sorry for not writing back on this one. You were totally right, it was the javascript_delay mixed with CSS not being specified. So I could solve it with a mix of the two.