Highcharts with Phantomjs

There might be situations when you want your web generated highcharts to appear in your pdf and ms word reports or documents. Highcharts by default are rendered as svg which are difficult to add in a pdf or ms word file generated via web browser. Below are few easy steps with which you can add your great highcharts to your pdf or word files.

Phantomjs is basically a tool with which you can take a snapshot of any remote url, save it as an image on your server and from there serve it in your download.

So, to add your generated highcharts in your files, you need to these steps
depending on your case.

1 – Make a route or file where the charts will be generated without any other headers, footers or backgrounds on the page. Let’s say render-chart.php

2 – Make a route or file where you formulate your report or document, hit the first url and get the location of image so that the image can be added into the file. e.g. generate-report.php

3 – Download the report with your contents and the generated image of the highchart.

1 thought on “Highcharts with Phantomjs

Leave a Reply

Your email address will not be published. Required fields are marked *