Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export Google Chart to PDF

I am using this gem for my RoR app: Google Visualr to generate some charts in my application. So I have code like this in my view:

<div id='chart'></div>
<%= render_chart @chart_data, 'chart' %>

That renders a Google Chart and I have to say it's pretty cool. However, how can I make a PDF from the chart? I was using the old Google image Charts and it was pretty easy to render the image to a pdf, but with this SVG I fail to see how to do it.

Any thoughts or recommendations?

like image 940
Hommer Smith Avatar asked May 24 '26 04:05

Hommer Smith


1 Answers

I'm not using Google Charts but I'm using Highcharts. I've found great success in rendering charts to pdf using a combination of 2 gems:

wicked_pdf - https://github.com/mileszs/wicked_pdf and wkhtmltopdf-binary - https://github.com/zakird/wkhtmltopdf_binary_gem

The second is the binary dependency for wicked_pdf. It was pretty straight forward to use and it can render your rails view in pdf format. If you plan on deploying on heroku, replace the second gem with:

wkhtmltopdf-heroku - https://github.com/bradphelan/wkhtmltopdf-heroku

like image 149
Chris Barretto Avatar answered May 25 '26 19:05

Chris Barretto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!