<!-- Circular Bar Chart start --> <div class="row"> <div class="large-12 large-centered columns chart-container"> <h2>Circular Bar Chart</h2> <div id="chart" class="text-center"></div> </div> </div>
Usually, when you add an image into a PDF with FDPF you use the following code. I’m simply appending the chart to the div id “chart”
// Insert image $pdf->Image('images/graphic_cropped.jpg',15,3,130);
How can I insert the chart that I generated with D3 into my PDF with FPDF?
Since FDPF is a server-side (php) library and you are generating the image on the client, you need to do something like this:
- Generate the chart
- Save chart to SVG (see, for example this question)
- Encode the image into base64 string (see, for example this)
- On php side – decode the base64 string back to binary image
- Now use FDPF to insert the image into PDF
You may also consider generating PDF on the client side.