Wednesday, 26 May 2021

Fabric JS loadSVGFromString include used defined custom attributes

I have an SVG string like this

<svg ...> <image id="Lager_1" data-name="Lager 1" width="2" height="3" xlink:href="data:image/png;base..." y="0" x="0" x_rel="0" y_rel="0" width_rel="0.2" height_rel="0.2" obj_id="0f83a8ca168e" comp_id="2c46c64a13c0"/> ...

I have added some extra attributes such as x_rel, y_rel, obj_id, and comp_id. However as soon as I try to load this SVG onto a canvas using FabricJS loadSVGFromString like this:

fabric.loadSVGFromString(svg, (objects, options) => {
    objects.forEach(obj => {
      console.log(obj)
      canvas.add(obj)
    })

And later outputting the contents of the canvas like this console.log(canvas) or console.log(canvas.toObject())

I see that my custom attributes have been lost and are no longer included, is there a solution for this?



from Fabric JS loadSVGFromString include used defined custom attributes

No comments:

Post a Comment