Dompdf convert canvas to pdf Dompdf convert canvas to pdf codeigniter codeigniter

Dompdf convert canvas to pdf


DomPDF is a HTML to DOM to PDF parser not a full fledged web browser.

Things are bound to not always work as intended and there may be differences in rendering.

If the canvas would be as simple as in the example you've provided there is no need to make it with javascript - just save it as png an include with <img src=""/>

If the picture generated on the canvas is more complicated and is dependent on the $data passed to view - which is probably the case - then you still have an option to use PHP to generate SVG (either view inline PHP or in the controller and passed with $data).

If SVG is not an option then you can use PHP GD (or other library) to generate the image and either save it in temporary location (and include the file in src="path/to/file.png") or transform the image to data URI and embed it in the view.

Personally, as a rule of thumb I wouldn't use anything more complex than a simple CSS and old plain HTML in the view