Reputation: 4962
This question has been asked before but I can't seem to get it to work. Hopefully you can see the error of my ways. The code below will capture the text and gray div but not the image.
<div id="snapshot" style="left: -60px; height: 1000px; width: 1000px;">
<p>THIS IS A TEXT TEST</p>
<div style="width: 100px; height: 100px; float: left; background: #f0f0f0">
</div>
<img src="http://photos.capturemyarizona.com/photos/LnnOEyWSV4fh846ohaIAQg/display.jpg" />
</div>
$("#myBtn").click ->
html2canvas $("#snapshot"),
background: "red"
onrendered: (canvas) ->
imgSrc = canvas.toDataURL()
popup = window.open(imgSrc)
return
return
<button id="myBtn">Click Me</button>
Here's the fiddle jsfiddle
Upvotes: 1
Views: 5673
Reputation: 4962
OK, well I figured out what the problem is. html2canvas can't capture an image if it's not from the same origin. My images are coming from a CDN.
Upvotes: 1