How to POST Highcharts Image?

天大地大妈咪最大 提交于 2019-12-25 02:19:02

问题


I need to create a PDF file which contains Highcharts.js chart and just wondering if there is a way to optimize the Export module to POST the image (png or jpeg) to a PHP file which I want to create the PDF files there.

As you know the exporting module normally exports the output as downloadable files but I do not want to download them just send them on the server.

Thanks


回答1:


You can use highchart's exporting module along with TCPDF Library. The TCPDF library Support svg rendaring.

You can use the exportApi

   chart.exportChart({
             url : 'export.php',
             filename: 'my-chart'
        }); 

Then use the example script a modified version from original SVG pdf example

Main part of the code is

$pdf->ImageSVG expect first parameter as string Name of the SVG file or a '@' character followed by the SVG data string.

$pdf->ImageSVG("@".$_POST['svg'], $x=15, $y=30, $w=200);

Happy coding!!

NB: You need to download the TCPDF library



来源:https://stackoverflow.com/questions/23308331/how-to-post-highcharts-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!