【问题标题】:Svg-edit load file into canvas programmaticallySvg-edit 以编程方式将文件加载到画布中
【发布时间】:2017-03-03 13:31:11
【问题描述】:

我正在尝试以编程方式在 Svg-edit 中加载文件(而不是通过标准的“打开文件按钮”)。我添加了新功能“Openclick”,它应该删除画布并将保存的 .svg 文件(之前在同一编辑器中创建)加载到画布中。画布已清理,但未加载文件(文件存在,数据在变量 xml 中)。请您帮助展示通过这种方式将数据加载到编辑器中的正确方法吗?

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);`  

【问题讨论】:

    标签: jquery canvas svg load svg-edit


    【解决方案1】:

    SVG-Edit 初始化全局变量svgEditor。 您需要使用此对象来运行loadFromURL/loadFromString/loadFromDataURI 函数。

    我有这样的东西可以将文件加载到 SVG-Edit

    $(document).ready(function() {
        svgEditor.loadFromURL("upload/file.svg");
    });
    

    【讨论】:

    • 如果可能的话,您能否分享一些测试示例来获取“svgEditor”,对我来说,在 angularjs- 1.5 中它变得空了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-01
    • 2018-07-09
    • 1970-01-01
    • 2010-11-28
    相关资源
    最近更新 更多