How to POST Highcharts Image?

2019-08-29 11:18发布

问题:

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