I struggled a bit with this, and the other answers were only partially useful to me. I would like to provide more details for everyone in the future:
The 4 main things that I did to fix this for us were:
(1) Do not use the middleware approach and instead use one of the built-in PDF files with rubies, based on the PDF layout that you create.
#Example layout file #app/views/layout/pdf.pdf.rb <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <%= wicked_pdf_stylesheet_link_tag "print" %> #print specific stylesheet <%= yield :head %> </head> <body> <h1>PDF Report</h1> <%= yield %> </body> </html>
(2) with the help of wicked_pdf helpers, upload ONLY the javascript that we need on these pages for the assets that we store in the application (all CDN-based resources can be loaded using regular javascript_include_tag)
#Example page template for a PDF you're downloading #app/views/users/profile.pdf.erb <% content_for :head do %> <%= javascript_include_tag "some_cdn.com" %> <%= wicked_pdf_javascript_include_tag "chartkick" %> <% end %> <p>All your pages content</p>
(3) using the javascript_delay option
(4) pass the "discrete axis" option, otherwise we saw only the axis and the data for the time diagrams (line / area / etc.)
source share