3

I am using canvg, but when I run this:

jQuery("#print").on("click", function() {
    mySvg();
});

function mySvg() {
    var svg = jQuery("#map svg");
  canvg(document.getElementById('canvas'), svg);
}

I get this in console

canvg.js:58 Uncaught TypeError: s.substr is not a function

Here it is a jsFiddle

Roberto Marras
  • 153
  • 2
  • 11
  • 3
    The second argument to `canvg` is annotated as follows in the source: `s: svg string, url to svg file, or xml document`. You're passing in a jQuery object. – Siguza Apr 12 '17 at 22:37

1 Answers1

3

Siguza is correct, you want to get the inner HTML of your SVG so (assuming #map is the direct parent of your target svg):

var svg = jQuery('#map');
var txt = svg.innerHTML;

Then you want to pass the txt variable as your second canvg() argument.