I am using Html5 and JQuery.
Html
<canvas style="border:1px solid grey;" id="cc" width="1000" height="800">
Javascript:
var pasteCatcher;
if (!window.Clipboard){
if(navigator.userAgent.indexOf("Firefox")>0){
pasteCatcher = document.createElement("div");
pasteCatcher.setAttribute("id", "paste_ff");
pasteCatcher.setAttribute("contenteditable", "");
pasteCatcher.style.cssText = 'opacity:0;position:fixed;top:0px;left:0px;';
pasteCatcher.style.marginLeft = "-20px";
document.body.appendChild(pasteCatcher);
pasteCatcher.focus();
document.getElementById('paste_ff').addEventListener('DOMSubtreeModified',function(){
if(pasteCatcher.children.length == 1){
var canvas = document.getElementById("cc");
var ctx = canvas.getContext("2d");
img = pasteCatcher.firstElementChild.src;
var img2 = new Image();
img2.onload = function(){
ctx.drawImage(img2, 0, 0);
}
img2.src = img;
pasteCatcher.innerHTML = '';
}
},false);
}
}
Above code is working fine. When the clipboard has image then that will be set to canvas. IF the clipboard has text then how can i get the text and draw in canvas?
Thanks!