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

Document adds "svg:" prefixes to all tags #182

Open
mathandy opened this issue Jul 15, 2022 · 0 comments
Open

Document adds "svg:" prefixes to all tags #182

mathandy opened this issue Jul 15, 2022 · 0 comments

Comments

@mathandy
Copy link
Owner

To make matters worse, Document.add_path() adds the path without the prefix, causing the path to not render in chrome.
Here's an example, which includes a little hack at the end as a workaround.

from svgpathtools import Document, Path, polygon

doc = Document('test.svg')

xmin, xmax, ymin, ymax = Path(*[seg for path in doc.paths() for seg in path]).bbox()
box = polygon(xmin+ymin*1j, xmax+ymin*1j, xmax+ymax*1j, xmin+ymax*1j)

doc.add_path(box, attribs={'stroke':"red", 'stroke-width':'0.1', 'fill': 'none'})

doc.save('test2.svg')


# fix for issue #182
with open('test2.svg') as f:
    txt = f.read().replace('<path', '<svg:path')
with open('test2.svg', 'w') as f:
    f.write(txt)

testing

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

1 participant