html2canvas可以在页面中呈现svg吗? [英] Can html2canvas render svg in a page?

查看:965
本文介绍了html2canvas可以在页面中呈现svg吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用html2canvas创建包含SVG的HTML页面的屏幕截图". 除了元素之外,一切看起来都不错. 我知道应该可以在Canvas中渲染SVG. PhantomJS,fabric.js和CanVG做到了.

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.

这是html2canvas不支持的东西吗?还是我做错了什么,这应该可以吗?

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

如果尚未实现,扩展html2canvas(使用canvg)的最佳方法是什么?

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

推荐答案

使用

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()">

请参见无参数调用示例. 转换完所有SVG图像后,html2canvas可以正常工作.

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

当然,所有SVG图像都将转换为画布,但是我看不出有什么区别.

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

这篇关于html2canvas可以在页面中呈现svg吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆