Skip to content

Cross domain and SVG not work #9

Closed
@brcontainer

Description

@brcontainer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions