phantomjs throwing DOM exception 18 on canvas.toDataURL using src images
I'm trying to convert svg to png images using phantomjs : var page = require('webpage').create(); page.evaluate(function() { var svg = '<svg class="tnt_tracks_svg" width="800" height="180" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/\ xlink"><rect width="10" height="10" fill="red"></rect></svg>'; var src = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(svg))); var img = new Image(); img.src = src; img.onload = function() { var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var context = canvas