New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save the Chart as a PDF #85

Closed
orwant opened this Issue May 9, 2015 · 41 comments

Comments

Projects
None yet
1 participant
@orwant
Copy link
Collaborator

orwant commented May 9, 2015

What would you like to see us add to this API?
A feature in the tool bar to export the chart or save a chart as a PDF.


What component is this issue related to (PieChart, LineChart, DataTable,
Query, etc)?
all the charts.

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by suresh.pasupuleti on 2009-10-13 20:23:32

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

This is from October? Has there been any movement on this? 

Original issue reported on code.google.com by Josh.Kehn on 2010-06-04 14:52:14

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I know this is a low priority enhancement, but still....

Original issue reported on code.google.com by roni.biran on 2011-10-11 13:22:03

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Everyone's response when we show them the charts created is 'How do I print it?

Original issue reported on code.google.com by wernerM on 2011-10-12 11:36:57

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I am developing a web server related to computational biology based on the Google charts
and it is crucial for our users to be able to easily include the charts into their
presentations. Currently they are forced to download the data and manually produce
an alternative plot, which defies the purpose of the charts

Original issue reported on code.google.com by korako on 2011-10-12 11:50:52

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Can we have a javascript image/buffer that uploads to a specific server url that is
part of the chart attributes? 

Original issue reported on code.google.com by fenil.rajkumar on 2011-10-12 16:06:19

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Is there any chance PDF export will ever happen ?

Original issue reported on code.google.com by darcy@qualitysystems.com on 2011-11-16 07:58:27

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Riccardo Govoni wrote a cool script that demonstrate how to convert the charts into
JPG/PNG images using an open source library that converts the SVG format into CANVAS
element, thus allowing you to save the image as a BASE64 image (which you can draw
into a PDF file)
Here is the link to all:
Thread: https://groups.google.com/forum/#!msg/google-visualization-api/LhMIMdNPTSg/8kJwHA9OQwsJ
Tutorial : http://www.battlehorse.net/page/topics/charts/save_google_charts_as_image.html
Example page: http://www.battlehorse.net/attach/topics/charts/google_charts_to_image.html
Source code : https://gist.github.com/1333906

Original issue reported on code.google.com by roni.biran on 2011-11-16 08:16:18

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

thanks! I will be checking that out. Could this approach not be folded into the official
library ?

Original issue reported on code.google.com by darcy@qualitysystems.com on 2011-11-16 11:34:20

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I believe that it will be at the end. But in the mean time this is the best thing out
there

Original issue reported on code.google.com by roni.biran on 2011-11-16 11:38:53

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

You can't save a PDF from Javascript! Chrome won't even let you access the file system
without a signed script. I don't think you could even manipulate binary byte arrays
with JS either.

Original issue reported on code.google.com by starrychloe@oliveyou.net on 2012-10-18 19:42:16

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

PNG would be awesome too. I know for a fact this is possible since Google uses this
themselves on Google.com/mobileplanet.

Original issue reported on code.google.com by Danny@upstream.nl on 2012-10-18 20:19:16

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I actually prefer PNG

Original issue reported on code.google.com by Danny@upstream.nl on 2012-10-18 20:21:36

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

You don't necessarily need access to the file system to save as PDF. Couldn't it just
stream the PDF bits to the browser like the way jsPDF does it?

http://code.google.com/p/jspdf/

The Javascript code does not need to "save" the PDF, it just needs to get the PSF viewer
to load it via the browser. The PDF viewer that would do the save, if the user clicks
File/Save (or equivalent) in it.

Original issue reported on code.google.com by denicomp on 2012-10-18 20:37:05

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I need it to be able to be imported into TCPDF.  If it was a PNG that would work also.
 I can make a line graph using the old depreciated system but I dont get the nice new
annotations, the dotted lines (certainty), etc..

Original issue reported on code.google.com by demutis on 2012-11-27 20:22:06

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Please provide option to export chart to pdf format.

Original issue reported on code.google.com by afroz.rules on 2013-01-02 10:15:46

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

There is actually a method to export charts in .jpg or .png?

Thank you

Original issue reported on code.google.com by marco.cinque.rm on 2013-02-21 13:23:35

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

@marco: there's look on answer #8

Original issue reported on code.google.com by SyZer3 on 2013-02-21 13:29:19

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

PDF format saving would be a 2-step process.  First save the canvas to JPG, and then
use TCPDF to import the JPG and save it as PDF.  It's very easy to do this in TCPDF.

Original issue reported on code.google.com by demutis on 2013-02-21 15:19:44

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

For anyone whois looking for a solution to save graphs to JPG/PNG, look into:
http://www.battlehorse.net/page/topics/charts/save_google_charts_as_image.html
http://stackoverflow.com/questions/13824096/save-google-charts-as-a-image
http://greenethumb.com/article/1429/user-friendly-image-saving-from-the-canvas/

Original issue reported on code.google.com by Danny@upstream.nl on 2013-03-08 16:04:01

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I can confirm the saving image from the canvas works, and it can be done as an automated
process.  We run 100 reports per day with 5 graphs on each report all automated.  

Original issue reported on code.google.com by demutis on 2013-03-08 16:26:36

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Coming back to this, I've combined several scripts which circled the web. I've come
up with a solution which exports the canvas to images including a customizable file
name and .PNG extension (previous scripts didn't allow for this). I'll make sure to
share it during the upcoming weekend.

Original issue reported on code.google.com by contact@dannyoosterveer.nl on 2013-03-22 19:05:14

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

This is what I have as well... except I store my images direct to mySQL
database.

On Fri, Mar 22, 2013 at 3:05 PM, <
google-visualization-api-issues@googlecode.com> wrote:

Original issue reported on code.google.com by demutis on 2013-03-22 19:52:05

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

@dannyoosterveer.nl sure they did :)

Original issue reported on code.google.com by SyZer3 on 2013-03-22 21:03:54

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

@dannyoosterveer.nl Can you share a link to your share. :) That would be nice.

Original issue reported on code.google.com by henrinijborg on 2013-08-21 14:46:19

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

@henry,
sorry it took some time, you can find it here: http://www.dannyoosterveer.nl/how-to-save-google-charts-visualizations-to-an-image-file-in-a-user-friendly-way/

Original issue reported on code.google.com by Danny@upstream.nl on 2013-09-15 23:46:48

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

@ Danny
Is there any way to download an image with extension without using PHP file

Original issue reported on code.google.com by primalvincent on 2013-10-16 06:11:37

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

there is.. read the tread. U may use pure js solution, but i never managed to get correct
non random file name. cheers!

Original issue reported on code.google.com by SyZer3 on 2013-10-16 07:28:17

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

when i convert the svg tags to svg image, it is thronging "Bad Base64 input character
at 9792: 59(decimal)" error in console, So i am not able to show this image in to pd4ml
pdf's. Please give me some solution.

Original issue reported on code.google.com by sathishmca1988 on 2013-11-11 12:06:41

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

you can find way to download google charts in pdf formate from here:

http://springtricks.blogspot.in/2013/10/how-to-download-charts-to-pdf-formate.html

Original issue reported on code.google.com by nahar.sachin8 on 2013-12-21 11:11:56

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

http://jsfiddle.net/spurgeom/je3Fy/  This is as close as i've managed to get to google
charts in a pdf 

Original issue reported on code.google.com by MSpurg73 on 2014-03-07 11:08:53

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

That's pretty amazing...  Although the quality is not great.  How do you
set the resolution or DPI?


On Fri, Mar 7, 2014 at 6:08 AM, <
google-visualization-api-issues@googlecode.com> wrote:

Original issue reported on code.google.com by demutis on 2014-03-07 13:24:53

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

That's where my problem lies, i'm doing this to create client reports but with the image
quality that poor it's not viable unless anyone knows how the image quality can be
improved? 

Original issue reported on code.google.com by MSpurg73 on 2014-03-10 11:31:55

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

I did a quick search online about jsPDF and resolution and found this: https://github.com/MrRio/jsPDF/issues/132

I hope this is enough to get you started solving the resolutions issue :)

Original issue reported on code.google.com by blurfus on 2014-03-10 13:50:29

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

(No text was entered with this change)

Original issue reported on code.google.com by michaelac@google.com on 2014-03-12 14:45:08

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

FYI, you no longer need to use the canVG hack to get image Data from a chart.

See: https://developers.google.com/chart/interactive/docs/printing 

You can combine this with jsPDF as mentioned above to get a PDF of the chart:
http://jsfiddle.net/S9rz2/3/

This has much higher fidelity, as it is not going through canvg to generate the image
data.

Original issue reported on code.google.com by trybka@google.com on 2014-04-28 17:35:01

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

(No text was entered with this change)

Original issue reported on code.google.com by dlaliberte@google.com on 2014-05-20 12:14:00

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Is this feature implemented? Can't find a reference in the changelog https://developers.google.com/chart/interactive/docs/release_notes#v25032014

Original issue reported on code.google.com by allon.moritz on 2014-05-20 12:27:23

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

As mentioned by trybka's comment, this feature is documented at https://developers.google.com/chart/interactive/docs/printing

We probably left it out of the release notes because early on, it was not very complete,
but it has been incrementally fixed over several releases.  If you notice any significant
differences with normally drawn charts, please let us know.

Original issue reported on code.google.com by dlaliberte@google.com on 2014-05-20 14:26:02

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

Are you able to use this with an Dashboard?

When I use getImageURI() in a chart in dashboard I got : 
" undefined is not a function "
error

Original issue reported on code.google.com by ddagenais@solutioncdr.com on 2014-05-21 19:08:19

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

How are you getting access to a chart object within the Dashboard?  getImageURI() only
applies to charts, not dashboards.

Original issue reported on code.google.com by dlaliberte@google.com on 2014-05-23 14:34:20

@orwant

This comment has been minimized.

Copy link
Collaborator

orwant commented May 9, 2015

To a timeline chart in a chart wrapper.
Le 2014-05-23 10:34, <google-visualization-api-issues@googlecode.com> a
écrit :

Original issue reported on code.google.com by ddagenais@solutioncdr.com on 2014-05-23 14:39:59

@orwant orwant closed this May 9, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment