I have to use sharp.js to produce PNG out of SVG that contains dynamic text. My question is, how to wrap long text in SVG elements and generate a PNG with sharp? Also if it is too long in height and width it should end up with 3 dots (...).
I tried the following one, but it has no effect.
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<rect fill="#CEE" width="100%" height="100%" />
<foreignObject x="20" y="90" width="150" height="200">
<p xmlns="http://www.w3.org/1999/xhtml">This is a very very looooooooooooong text, it should have a line break on the end and continue on the next line, then. if it is too long it should end with ...</p>
</foreignObject>
</svg>
and then
sharp(Buffer.from(svg))
.png()
.toFile(fileName)
.catch(console.log)