I am using Rails 4
I followed instruction from https://github.com/pdfkit/pdfkit
In controller I have
respond_to do |format|
format.html {render layout:'application'}
format.csv {send_data @testdatares.to_csv}
format.pdf {
html = render_to_string(:layout => 'application' , :action => "testpage.html.erb");
kit = PDFKit.new(html);
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/application.css";
send_data(kit.to_pdf, :filename => "some_name.pdf", :type => 'application/pdf')
}
end
In application.html.erb I have
<!DOCTYPE html>
<html>
<head>
<title>STNEW</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag "http://www.google.com/jsapi", "/usr/local/lib/ruby/gems/2.1.0/gems/chartkick-1.3.2/app/assets/javascripts/chartkick",media:'all' %>
<%= csrf_meta_tags %>
</head>
Please note that I already used absolute path to chartkick.js
Now in html the chartkick contents were perfectly displayed.
But in the pdf file generated by pdfkit all chartkick contents were shown as "loading", while text was correctly shown
Googled around but found no answer