ibrahimjan Posted December 1, 2011 Share Posted December 1, 2011 Hi all, I am creating an SVG file dynamically, i need to convert the following inside the SVG file: <text transform="matrix(1 0 0 1 13 444)" fill="#00FF00" style="line-height:50px" font-size="24">Line1<br>line2<br>line3<br>line4<br></text> The line brakes and the "line-height" don't work inside the SVG file so I think a small java script inside the file to convert what ever <br> to the following before the SVG file loads the elements: <text transform="matrix(1 0 0 1 13 444)" fill="#00FF00" font-size="24">Line1<tspan x="0" dy="50px">Line2</tspan><tspan x="0" dy="50px">Line3</tspan><tspan x="0" dy="50px">Line4</tspan></text> any Ideas is much appreciated. Thanks Link to comment Share on other sites More sharing options...
boen_robot Posted December 3, 2011 Share Posted December 3, 2011 This shouldn't be a valid XML... <br> elements should be <br /> instead.If you can fix that, you can use DOM to get all <br /> elements, get their nextSibling property, and afterwards, replace each <br /> with a new tspan with the captured nextSibling as text. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.