使用html2canvas创建网页截图(无法正确初始化) [英] create screenshot of webpage using html2canvas (unable to initialize properly)
问题描述
我尝试使用 http://html2canvas.hertzen.com/ 截取我的截图网页。我无法使用...初始化一个画布元素。
var canvas = $('body')。html2canvas();
如果我能够得到一个合适的画布,我会遵循像
var dataUrl = canvas.toDataURL(); //获取图像字符串
window.open(dataUrl); //显示图像
不幸的是,文件是非常有限的IMO。 http://html2canvas.hertzen.com/documentation.html 。我不相信我需要预先加载,因为我没有使用任何动态图形(但我甚至没有得到这么远)反正我不能理解这是否是这样这个人在使用html2canvas进行屏幕截图方面取得了成功
我似乎没有得到任何远远超过这个家伙..
如何使用html2canvas上传截图? 我的理想解决方案将演示如何使用最少的代码创建屏幕截图。 (复制html到canvas。get toDataURL string。output字符串)
任何洞察力都非常值得赞赏=)
您应该这样使用它:
$('body' ).html2canvas();
var queue = html2canvas.Parse();
var canvas = html2canvas.Renderer(queue,{elements:{length:1}});
var img = canvas.toDataURL();
window.open(img);
花了我几个小时才弄明白,如何正确使用它。
由于插件的不完整,需要 {elements:{length:1}}
>,否则会出错。
祝你好运!
I am attempting to use http://html2canvas.hertzen.com/ to take screenshots of my webpage. I am unable to initialize a canvas element using...
var canvas = $('body').html2canvas();
If I were able to get a proper canvas I would follow with something like
var dataUrl = canvas.toDataURL(); //get's image string
window.open(dataUrl); // display image
Unfortunately, the documentations is very limited IMO. http://html2canvas.hertzen.com/documentation.html . I do not believe I need to preload as I am not using any dynamic graphics(but am not even getting that far anyways)
I am simply too noob to understand if this guy is having success with screen capturing using html2canvas
I don't seem to be getting any farther than this fellow.. How to upload a screenshot using html2canvas?
My ideal solution would demonstrate how to create screenshot with minimal code. (Copy html to canvas. get toDataURL string. output string)
ANY insight is GREATLY appreciated =)
You should use it this way:
$('body').html2canvas();
var queue = html2canvas.Parse();
var canvas = html2canvas.Renderer(queue,{elements:{length:1}});
var img = canvas.toDataURL();
window.open(img);
It took me few hours to figure it out, how to use it the right way.
The {elements:{length:1}}
is required, due to incomplete implementation of the plugin, otherwise you'll get an error.
Good luck!
这篇关于使用html2canvas创建网页截图(无法正确初始化)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!