Q:

Canvas.toDataURL() Issue. Is there an alternative?

Probably this has been brought up many times. But i need to get a final answer to it. 
I have an SVG file loaded onto a browser using an object html tag. Using javascript and the DOM, the user alters that file and customizes its colors elements and alot more. Basically it is a customizer of a jacket. I am not using canvas for this. This is pure svg exported from illustrator and altered.
All is going well until the point where i have to export the altered version of this svg to the server to create a pdf document that contains this customized image. Obviously i need to send an ajax request to the server which contains the base64 string of this image.
Anyone i ask will say that i should create an image via javascript, assign the src attribute to the SVG's serialized XML and then draw it to a canvas to extract the base64 string.
All is well until i hit the toDataURL() method (or getImageData() method). It is only working on Firefox. Other browsers are throwing the security breach exception. That is obviously unacceptable. 
I have lost hope to get this done since drawing the image to the canvas is tainting it. Is there a way to work around this issue without changing the whole structure of the webpage? 

A:

I solved the .toDataURL() issue by using fabric js.
var a = document.getElementById("theSVG"); //This is the <object>
a.setAttribute('data', 'worldmap.svg'); //Setting the data attribute to the svg file

a.onload = function () {

    var svgDoc = a.contentDocument;
    var s = new XMLSerializer();
    var xml = s.serializeToString(svgDoc);
    xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');

    var canvas = new fabric.Canvas('canvas');

    var svg = xml;

    fabric.loadSVGFromString(svg, function (objects, options) {
        var loadedObject = fabric.util.groupSVGElements(objects, options);
        canvas.add(loadedObject);
        canvas.calcOffset();
        canvas.renderAll();
        if (!fabric.Canvas.supports('toDataURL')) {
            alert('This browser doesn\'t provide means to serialize canvas to an image');
        }
        else {
            window.open(canvas.toDataURL('png'));
        }

    });
}

This got me through the .toDataURL() issue but now new things came up so wish me luck.

