1

I am trying to load file in Svg-edit programmatically (not through standard "Open file button"). I added new function "Openclick", it should delete canvas and load saved .svg file (created previously in same editor) into canvas. Canvas is cleaned, but file is not loaded (file exist, data are in variable xml). Please can you help show correct way to load data into editor by this way ?

setTimeout(
  function() 
  {

 var url_adress="files/upload/"+file_name+".svg";
     $.ajax({
    url: url_adress,
    type: 'GET',
    dataType: 'text',
    timeout: 100,
    error: function(){
    alert('Error loading XML document');
    },
    success: function(xml){
          svgCanvas.clear(); // clear Canvas first
          svgCanvas.setSvgString(xml); // load file into editor
    }
});


  }, 1200);`  
mira
  • 1,056
  • 3
  • 15
  • 32

1 Answers1

2

SVG-Edit initialize global variable svgEditor. You need to use this object to run loadFromURL/loadFromString/loadFromDataURI functions.

I have something like this to load file into SVG-Edit.

$(document).ready(function() {
    svgEditor.loadFromURL("upload/file.svg");
});
Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53
Danioo
  • 21
  • 3