Error: Unbound namespace prefix: "svgjs"
BuyingANew-Soul opened this issue · 0 comments
I am trying to create a svg file from some existing svg elements.
<g id="XL_P8_5_1"> <path id="XL_P8_Outline_4__1" fill="none" stroke="#000000" stroke-miterlimit="10" d="M5299.... "> </path> <path id="XL_Base_49__1" fill="#1E1E29" d="M5299... "> </path> <g id="XL_P8_5_1extra_1"> <text transform="matrix(0.7257 -0.2285 0.3004 0.9538 5258.6953 5362.7295)" x="0" y="0" svgjs:data="{"leading":"1.3"}"> <tspan x="0" y="0" fill="#E74810" font-family="'ArialMT'" font-size="5px">Code:BR 4001, Size:X </tspan> <tspan x="50.029" y="0" fill="#E74810" font-family="'ArialMT'" font-size="5px">L</tspan> </text> </g> </g> <g id="XL_P8_5_2"> <path id="XL_P8_Outline_4__2" fill="none" stroke="#000000" stroke-miterlimit="10" d="M5925... "> </path> <path id="XL_Base_49__2" fill="#1E1E29" d="M5925... "> </path> <g id="XL_P8_5_1extra_2"> <text transform="matrix(0.7257 -0.2285 0.3004 0.9538 5258.6953 5362.7295)" x="784.402007239456" y="187.9176542820469" svgjs:data="{"leading":"1.3"}"> <tspan x="0" y="0" fill="#E74810" font-family="'ArialMT'" font-size="5px">Code:BR 4001, Size:X </tspan> <tspan x="50.029" y="0" fill="#E74810" font-family="'ArialMT'" font-size="5px">L</tspan> </text> </g> </g>
This is the structure of the elements. I am holding this as a string in a variable named "elements" and trying to create a svg file as follows:
`
const { createSVGWindow } = require('svgdom')
const window = createSVGWindow()
const document = window.document
const { SVG, registerWindow } = require('@svgdotjs/svg.js')
// register window and document
registerWindow(window, document);
const svgFromString = (string) => {
const draw = SVG(document.documentElement);
var svg = draw.svg(string);
return svg;
};
var newsvg = svgFromString(elements)
`
I am getting this error: Unbound namespace prefix: "svgjs" on the last line. I am able to create svg this way with similar files, but getting error on these specific svg files, from where the elements were taken.
[https://drive.google.com/file/d/1sxDc1-XsB0cip575btGCG6yHw7VNuZqy/view](here is svg file I'm working with)