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

trifek's avatar

Save charts to PDF in Laravel

Hi, I am beginner. I make my project in Laravel 8. I use components: https://www.chartjs.org and barryvdh/laravel-dompdf , fx3costa/laravelchartjs. In view I have chart. It's work fine, but in PDF my chart is invisible. I found info with information about Dompdf has problem with js.

Do you know any way to add charts to PDF in this library or some other?

0 likes
1 reply
fylzero's avatar

@trifek You'll want to use a third party service or a package like this.

https://github.com/spatie/browsershot

I recommend the above package if you server supports Puppeteer.

Charts can't simply be exported because they are created on canvas elements dynamically. Only way to really export is to use something to capture an image then inject into the PDF. Hope that helps.

2 likes

Please or to participate in this conversation.