Open matthieu80 opened 8 years ago
This might help:
window_status: 'done_with_heatmap'
which waits to render through wkhtmltopdf until some JS sets window.status to the given string, so you could trigger that with something like this:
// setup_heatmapstuff.then(function() {
window.status = 'done_with_heatmap';
});
You might also be able to use no_stop_slow_scripts: true
.
Also, bear in mind that some of these options are exclusive of others, so adding all 3 strategies probably won't work.
Let me know how it goes!
thank you for your answer! Here is my original code in the controller:
respond_to do |format|
format.html
format.pdf do
render :pdf => "file_name",
:save_to_file => Rails.root.join("file.pdf"),
:layout => "/layouts/print_layout.html.erb",
:javascript_delay => 10000
end
end
The other solutions do not work
'done_with_heatmap' strategy gives the same result (maps are displayed with rich marker, but no heatmap)
controller:
respond_to do |format|
format.html
format.pdf do
render :pdf => "file_name",
:save_to_file => Rails.root.join("file.pdf"),
:layout => "/layouts/print_layout.html.erb",
:window_status => 'done_with_heatmap'
end
end
no_stop_slow_scripts: true Strategy
respond_to do |format|
format.html
format.pdf do
render :pdf => "file_name",
:save_to_file => Rails.root.join("file.pdf"),
:layout => "/layouts/print_layout.html.erb",
:no_stop_slow_scripts => true
end
end
this throws an error:
Error: Failed to execute: ["/Users/matthieuvigneron/.rbenv/versions/2.2.2/bin/wkhtmltopdf", "-q", "--no-stop-slow-scripts", "true", "file:////var/folders/1h/kqzm7y_x77nf7s113d3zcqmw0000gn/T/wicked_pdf20160914-21836-n0k8cc.html", "/var/folders/1h/kqzm7y_x77nf7s113d3zcqmw0000gn/T/wicked_pdf_generated_file20160914-21836-1y17nie.pdf"] Error: PDF could not be generated! Command Error: Error: Failed loading page http://true (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError
Also, my Gemfile looks like that (without wkhtmltopdf-binary-edge maps are not displayed):
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge', '~> 0.12.2.1'
I might just do something wrong, cannot see it though...
Can you provide a sample html or Rails view file that I can reproduce the issue with?
@matthieu80 did you find a solution for this issue? I'm facing a very similar problem right now.
Hello! Did anyone find a solution for this yet? @hitchcockwill @matthieu80 , I'm facing a similar problem with jvectormap and a map I need to show on the PDF. I've tried to use the slow generation and adding the js as assets in the app/assets folder but the map is still not showing.
Hi there, I am creating a pdf with multiple google maps. Each maps are including rich markers and a heat map. While the maps and the rich markers are working fine, the HeatmapLayer does not render. I tried with a javascript delay set to 10 000 ms... The same page renders perfectly well in HTML. I have been turning in circle for hours, any idea is welcome :)