Created
October 29, 2015 16:25
-
-
Save FilmKnurd/813bf8393a4a78e70e1f to your computer and use it in GitHub Desktop.
iFrame to image using domvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.getElementById('canvas-id'); | |
var context = canvas.getContext('2d'); | |
var idoc = document.getElementById('iframe-id').contentWindow.document.body; | |
domvas.toImage(idoc, function() { | |
context.drawImage(this, 0, 0, width, height); | |
// Download | |
var rawImageData = canvas.toDataURL("image/png;base64"); | |
rawImageData = rawImageData.replace("image/png", "image/octet-stream"); | |
document.location.href = rawImageData; | |
}, width, height); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment