Cross domain and SVG not work
brcontainer opened this issue · 1 comments
brcontainer commented
Note: This question/issue has been established to guide proxy servers.
If my html/script is on a domain like this http://www.example.com
and the proxy in another like this http://proxy.example.com
(or http://www.example2.com
) the script fails to convert the images to canvas, see example:
<script>
//<![CDATA[
(function() {
window.onload = function(){
html2canvas(document.body, {
"logging": true, //Enable log (use Web Console for get Errors and Warnings)
"proxy":"http://proxy.example.com/html2canvasproxy.php", //or "proxy":"http://www.example2.com/html2canvasproxy.php"
"onrendered": function(canvas) {
var img = new Image();
img.onload = function() {
img.onload = null;
document.body.appendChild(img);
};
img.src = canvas.toDataURL("image/png");
}
});
};
})();
//]]>
</script>
Script show this error:
Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': tainted canvases may not be exported.
And the proxy don't support SVG images.
brcontainer commented
Enhancements applied in 0.1.10 version b30f496
Read how to use "cross-domain":
https://github.com/brcontainer/html2canvas-php-proxy/#run-script-in-cross-domain-data-uri-scheme