PHP - Highcharts - PDF

1

I'm using Mpdf to make some values I've saved in SESSIONS in php become a report, so that's fine, but the page I want to turn into report has Highcharts Js graphics, I do not know how to export those graphics directly for the report that will be in pdf.

Website: link

Steps: Click Carbon per filter (menu) > > calculate carbon > > WHRC

    
asked by anonymous 17.02.2016 / 18:04

2 answers

2
Unfortunately, mpdf does not support javascript, so in order for you to show a highchart in your pdf you will have to export it in image format.

An example of this would be:

var hightchart = $('#container').highcharts().getSVG(); // Pega o highcharts e transforma em SVG.

Send the result by ajax to php, and then include it in your mpdf:

$html = "Olha um gráfico: ". $_POST['hightchart '];

include 'lib/mpdf/mpdf.php';
$mpdf = new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output('exemplo.pdf', 'I'); 

Example: Transforming graphic into image

Documentation: Highcharts Chart.getSVG

    
17.02.2016 / 18:29
-1

To generate PDF tries to use a library called wkhtmltopdf, it is an interesting project that transforms into PDF the page rendered by the webkit, Google rendering engine.

If graphics are empty, try disabling highcharts animations.

    
17.02.2016 / 19:55