Inserting Graphs into DomPDF

Viewed 3713

Is there any way in getting graphs to show within a pdf that is being generated using DOMPDF for Laravel. I am currently using charts.js to create the graphs and I can get them so that you click to convert the graph to an image, however this will not put them into the PDF.

The PDF's will automatically generate so using PHP/Laravel I need the system to load the chart, convert it to an image and insert into the PDF. Is this possible?

1 Answers

Even though it's been a while I faced a similar problem. My solution was first generating the charts, save them as an image and simply use those images in DOMPDF.

The solution I used is called pChart.

After generating the chart you can save it to a file using:

$myPicture->render("image.png");

For more information see the documentation

Related