Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can html2canvas render svg in a page?

I am using html2canvas to create a 'screenshot' of a HTML page that contains SVG. Everything looks good, except the element. I know that it should be possible to render SVG in Canvas; PhantomJS, fabric.js and CanVG do it.

Is this something that html2canvas does not support? Or am I doing something wrong, and this should just work?

If this has not been implemented, what is the best way to extend html2canvas (using canvg)?

like image 460
rakensi Avatar asked Jan 04 '13 21:01

rakensi


1 Answers

Capturing SVG images works by transforming them into canvas, using canvg. Include both javascript files as indicated on that page. Then the easiest way to do this is:

<body onload="canvg()">

See the parameterless call example. When all SVG images have been converted, html2canvas works flawlessly.

Of course, all SVG images will be converted to canvases, but I did not see a difference.

like image 92
rakensi Avatar answered Oct 05 '22 17:10

rakensi