javascript - Is it possible to get a "screen shot" of only a single div -
i want users able take picture programmatically of design have made on site . design in div panorama extends off both left/right edge of screen.
basically create .jpg, .png, etc of div , it's contents.
is possible image magic , combination of other plugins?
i've found way download 'screenshot' of single div using html2canvas (here's link: http://html2canvas.hertzen.com/) library. code generate canvas based on html of div, doesn't display it, converts canvas image (in case png image file) provides download link connected generated image:
html:
<div id="capture"><h2>this should save image</h2><p>amazing!</p></div> <p id="notice"></p>
javascript:
html2canvas($("#capture"), { onrendered: function(canvas){ img = canvas.todataurl(); document.getelementbyid("notice").innerhtml = "<a href='"+img+"' download='download.png'>click here</a> download image"; } });
here's link working jsfiddle: http://jsfiddle.net/xanco/kj5s5/ don't hesitate contact me if have more questions
Comments
Post a Comment