4 ms·
A poor man's version is to draw it onto a canvas and save the canvas, e.g.: var svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="100"
by ceautery 10y ago
A poor man's version is to draw it onto a canvas and save the canvas, e.g.:
var svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>';
i = new Image();
var cnv = document.createElement('canvas');
var ctx = cnv.getContext('2d');
i.onload = function() {
ctx.drawImage(i, 0, 0);
console.log(cnv.toDataURL());
}
i.src = 'data:image/svg+xml;base64,'+ btoa(svg);
- thom 10y agoNow copy across all styles, embed all fonts and external images etc etc etc. Nightmare.