Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text element support #16

Closed
topochico-one opened this issue Jul 22, 2022 · 3 comments
Closed

Text element support #16

topochico-one opened this issue Jul 22, 2022 · 3 comments

Comments

@topochico-one
Copy link

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>
@laurmaedje
Copy link
Member

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.

@laurmaedje
Copy link
Member

This should probably be explained in the documentation, we can keep this issue open to track that.

@topochico-one
Copy link
Author

Ah this makes sense! Thank you for the super fast response!

@reknih reknih closed this as completed Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants