Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fbc's avatar
Level 2

Laravel charts to PDF possible??

I am using Laravel charts to generate charts for a report on the screen. However, I would like for those charts to appear in a PDF report as well.

I installed barryvdh/laravel-dompdf and have created PDF reports but have yet been able to create one that includes the charts. The area where the chart should be just shows up as blank space.

What is the easiest route to get a chart to show up in a PDF files?

0 likes
8 replies
artcore's avatar

Depending on your charts app you can export them as image and add to pdf easily. e.g. highCharts that has this option via their api or locally with e.g. phantomJS but I never went through that hassle. https://export.highcharts.com/

jacoboospina's avatar

Hi! I'm about to start a project where I actually need to do something similar.... I was curious if you made it work because I'm reading articles forums etc and it seems that everyone is facing same error (not printing the chart in the pdf), so if you could help me with this I will apreciate it. Thank you in advance

fbc's avatar
Level 2

It depends on which library you choose to use as some have support for Javascript.

I used barryvdh/laravel-dompdf which has an

isJavascriptEnabled: true (available in config/dompdf.php)

available, but I have not tried it to get my charts working. I had to move on with other things and left this for later. So if you enable Javascript and are able to get it working and showing your charts, please let me know. Or if you decided to do something different, let me know as well. Thanks

fbc's avatar
Level 2

How would you make that example work for consoletvs/charts?

artcore's avatar

I wouldn't but you could extend consoletvs class I suppose. The end goal is to send a curl request to the highcharts api and it'll send back the image for you to store and use anywhere. See where they create the json object for the frontend js options and use that logic or resultset for your export method.

jacoboospina's avatar

So the thing you would do is to create a JSON with the chart's data and send it to highcharts and in response I will get the chart as an image? So I can either store it or print it in a PDF?

jacoboospina's avatar

So I finally got to print a Chart in a pdf... I used pChart 2.0 libray which let you create the chart and then save it as a png to your server (or instant print it in your browser). If you need anything from my code I will be happy to help.

Please or to participate in this conversation.