Open samgville opened 6 years ago
It is certainly possible for wkhtmltopdf
to render a jvectormap.
You can see it working by calling wkhtmltopdf http://jvectormap.com/examples/world-gdp/ output.pdf
on the command-line
However, I tried to reproduce your issue and had a similar result (blank where the map should be). But if I called wkhtmltopdf http://localhost:3000/my_wicked_pdf_endpoint
(HTML version) it would render the map.
This leads me to suspect it is related to a content security policy or something interfering with loading from a file vs from a webpage.
I don't have a solid answer for you at this time, and I need to go AFK for awhile, but wanted you to be aware of my findings.
You could potentially work around this by shelling out in one endpoint to load another (though this may cause a deadlock in development mode if you are using a webserver that is configured to be single-threaded like Webrick).
Let me know how it goes or if you find any potential reasons for this behavior before I do.
Additionally, I was able to get it working by rendering just the HTML from a controller action, then targeting that with the Rack Middleware options
__config/initializers/wicked_pdf.rb__
WickedPdf.config = {
#:wkhtmltopdf => '/usr/local/bin/wkhtmltopdf',
#:layout => "pdf.html",
# exe_path: '/usr/local/bin/wkhtmltopdf'
}
config_709 = {
page_size: "Letter",
margin: { bottom: 0,
top: 0,
left: 0,
right: 0 }
}
Rails.application.config.middleware.use WickedPdf::Middleware, config_709, only: '/pages/issue_709' # my jvectormap endpoint
I added an example to the wicked_pdf_issues project to show how I got it working: https://github.com/unixmonkey/wicked_pdf_issues/commit/a747bd7b8df1740993414c522fa1cb5adc4ac963
https://wicked-pdf-issues.herokuapp.com/pages/issue_709.pdf
I hope this helps!
Hey @unixmonkey thanks for your help we got this working yesterday using that Middelware, we are having an issue now with Google Charts, the same one we had with Jvectormap, We will continue working on this matter and let you know if we found a solution for that too. Thanks!
Hello,
I'm using Wicked PDF to generate a report which shows a Map generated by jvectormap and a Bar Chart that is generated with Google Charts.
I'm using this two gems 'wicked_pdf' and 'wkhtmltopdf-binary-edge'. I have set a JavaScript delay on the respond_to Method of 50000m and on the initializers we have specified the path of the needed wicked gems. And then I'm using a pdf_layout.html.erb where we set the pdf generation.
Here are the files I'm talking about: Gemfile:
Controller: respond_to format
The PDF Layout:
The map and the charts are showing in the HTML online view but not when you generate the pdf.
Is this enough information to report an issue? Or do you need more code to be shown?