svg2pdf
svg2pdf copied to clipboard
Text element support
Thanks for creating svg2pdf! Does it support text elements? I get a blank PDF when I try to convert the following SVG:
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="600" height="300">
<text x="0" y="15" fill="red">I love SVG</text>
</svg>
svg2pdf
uses usvg
behind the scenes to convert the SVG to a simpler representation. This also includes converting text to curves. So to correctly render text, you have to manually create a usvg::Tree
from your string (providing fonts) and then use convert_tree
instead of convert_str
. You can see how it's done in svg2pdf's CLI here.
This should probably be explained in the documentation, we can keep this issue open to track that.
Ah this makes sense! Thank you for the super fast response!