将Google图表保存为PDF [英] Save google charts as pdf

查看:102
本文介绍了将Google图表保存为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将这个饼图保存为pdf文件,如 http://keepcoding.ehsanabbasi.com/php/convert-google-chart-to-png-and-pdf/
在php.chartsrc中显示了以下值比png图片源

I am trying to save the piechart as a pdf file as in http://keepcoding.ehsanabbasi.com/php/convert-google-chart-to-png-and-pdf/ Having javascript inside php.chartsrc shows up the following value rather than the png image source

function(){if(!this.b ||!this。$ ||!this.Ua)抛出m(Chart has not finished drawing。); var a = new Ql(this.V,this.Aa),b = Tl(this.ma)[Wb](ih),a = YO(b,a )a = new EO(b,a),c = new RO(b),a = this.sO(c,a),c = yY(this.ig,this。$,this.Ua); a。 Lp(this。$,c); return b [cc] [0] .toDataURL(Ssa)} failed(文件系统路径'/ var / www / html / function(){if(!this.b ||!this。 $ ||!this.Ua)throw m(Chart has not finished drawing。); var a = new Ql(this.V,this.Aa),b = Tl(this.ma)[Wb](ih) ,a = YO(b,a),a =新EO(b,a),c =新RO(b),a = this.sO(c,a),c = yY(this.ig,this。$ ,this.Ua); a.Lp(this。$,c); return b [cc] [0] .toDataURL(Ssa)}')

 $script ="

        google.setOnLoadCallback(drawChart);
        function drawChart() { //code for drawing chart}
        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        google.visualization.events.addListener(chart, 'ready', function ()      {
        var chartsrc = chart.getImageURI();
     });

      $doc->addScriptDeclaration($script);
      echo "<div id='piechart'></div>";


推荐答案

我们在@cloudformatter中增加了支持,以支持所有Google图表输出为PDF,图像,XPS和其他格式。您可以查看下面的链接。

We added support in our @cloudformatter to support all Google Charts output to PDF, Image, XPS and other formats. You can take a look at the links below.

Google Charts @cloudformatter支持页面:
http://www.cloudformatter.com/GoogleCharts

Google Charts @cloudformatter support page: http://www.cloudformatter.com/GoogleCharts

整个Javascript的文档:
< a href =http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage =noreferrer> http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage

Documentation for the overall Javascript: http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage

上面的Google Charts网页中有一些关于实现Handler的提示,它在图表绘制后将SVG名称空间添加到生成的SVG中。

There are a few hints on the Google Charts web page above about implementing a Handler that adds the SVG namespace to the generated SVG after the chart draws.

您可以从顶部的菜单中进行选择以格式化整个页面,甚至可以从内联菜单中选择仅将特定图表格式化为PDF(或其他格式)。

You can choose from the menu at the top to format the whole page or even choose from the menus inline to format only a particular chart to PDF (or other formats).

这里还有一个小提琴: http://jsfiddle.net/zvx6eb7e/10 / ,在PDF按钮后面生成PDF的代码仅此:

There is also a fiddle to play with here: http://jsfiddle.net/zvx6eb7e/10/, the code to produce PDF behind the PDF button is only this:

var click="return xepOnline.Formatter.Format('JSFiddle', {render:'download', srctype:'svg'})";
jQuery('#buttons').append('<button onclick="'+ click +'">PDF</button>');

我会注意一件事---这不是图像转换为PDF,这是图表矢量转换为PDF以获得最高分辨率和最佳数据表示。

I would note one thing --- this is not chart to image to PDF, this is chart in vector to PDF for the highest resolution and best representation of the data.

这篇关于将Google图表保存为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆