Can html2canvas render svg in a page?

女生的网名这么多〃 提交于 2019-12-18 21:12:11

问题


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)?


回答1:


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.



来源:https://stackoverflow.com/questions/14165426/can-html2canvas-render-svg-in-a-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!