1

I have a page with several chartkick charts which use the google charts js library which for speed purposes I copied to my server and load in the layout with a <%= javascript_include_tag 'jsapi', 'chartkick' %> tag.

When I want to call the .pdf extension for the middleware on a page I get the following error:

I, [2015-10-06T18:52:24.936813 #13267]  INFO -- : Started GET "/javascripts/jsapi.js" for 127.0.0.1 at 2015-10-06 18:52:24 +0000
F, [2015-10-06T18:52:24.955713 #13267] FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/javascripts/jsapi.js"):

Why is pdfkit looking for a route? As an FYI, if I set disable_javascript: true in the PDFKit initializer, I have no error rendering the page but of course the charts are not drawn.

How can I have the JS render the charts and make a PDF out of it?

INFO:

Rails 4.2 Ubuntu 14.04 wkhtmltopdf 0.9.6 pdfkit: 0.8.2 (latest)

EDIT:

This is not a duplicate of this because even with static links for the JS files (see comment) PDFKit still tries to match a route for javascripts/jsapi.js

Killerpixler
  • 4,200
  • 11
  • 42
  • 82
  • Possible duplicate of [generating pdf hangs on rails 4 using PDFkit gem](http://stackoverflow.com/questions/17908359/generating-pdf-hangs-on-rails-4-using-pdfkit-gem) – Sean Huber Oct 06 '15 at 19:54
  • Take a look at this answer: http://stackoverflow.com/questions/17908359/generating-pdf-hangs-on-rails-4-using-pdfkit-gem wkhtmltopdf requires absolute urls for assets but `<%= javascript_include_tag 'jsapi', 'chartkick' %>` will generate a a relative one instead. – Sean Huber Oct 06 '15 at 19:55
  • Not a duplicate, I tried setting the asset host config, and now looking at the source it shows the stylsheets as `https://my.host.com/javascripts/jsapi.js` and so on for the others. However the rails error log still shows the No Route Matches error i described above – Killerpixler Oct 07 '15 at 12:27

0 Answers0