Forum How do I...?

How to display canvas image in PDF?

Jeffrin
I am using jqplot chart package. I generated a chart and it is in canvas. When I give it to prince, it doesn't render me the chart. How to fix this?
mikeday
Unfortunately jqplot won't work in Prince as it uses DOM features we haven't implemented yet, so it is necessary to generate the graphs as images or SVG some other way first, such as with an external script or by using PhantomJS.
ManojOjas
I am using canvas to display chart in my page. i generate a PDF using prince which is not rendering canvas on PDF. how to fix this ?
mikeday
Have you enabled JavaScript? Which chart library are you using? Prince does not support every charting library, unfortunately.
ManojOjas
I am using HTML 5 canvas object to display charts.
mikeday
Have you enabled JavaScript?
ManojOjas
Yes mikeday JavaScript is enabled
mikeday
Are there any errors or warnings in the log?
ManojOjas
Hi mikeday

I am sending you some code which is generating inside logfile


Fri Nov 3 14:03:27 2017: ---- begin
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/css: warning: The requested URL returned error: 404 Not Found
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/icon: warning: The requested URL returned error: 404 Not Found
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/bootstrap.min.css:5: warning: unknown media feature 'transform-3d'
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/bootstrap.min.css:5: warning: bad color value '#000\9 '
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro.html: warning: unsupported properties: box-shadow
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/app.css: warning: unsupported properties: box-shadow
Fri Nov 3 14:03:29 2017: http://www.astrosage.com/kundali-tool/html2pdf-bighoro_files/bootstrap.min.css: warning: unsupported properties: box-shadow, line-break, pointer-events, text-shadow
Fri Nov 3 14:03:30 2017: page 1: warning: no font for Private Use Area character U+E5CD, fallback to '?'
Fri Nov 3 14:03:30 2017: page 1: warning: no font for Private Use Area character U+E8CC, fallback to '?'
Fri Nov 3 14:03:30 2017: page 8: warning: no font for Private Use Area character U+E315, fallback to '?'
Fri Nov 3 14:03:30 2017: page 8: warning: no font for Private Use Area character U+E314, fallback to '?'
Fri Nov 3 14:03:31 2017: finished: success
Fri Nov 3 14:03:31 2017: ---- end
mikeday
Nothing relating to JavaScript, perhaps try adding <script>alert('test');</script> just to check it's running?