I'm attempting to write a script that adds text to an svg image at a certain location. I'm aware that Inkscape has a very robust command interface but there doesn't seem to be much in the way of documentation on this matter. How might I accomplish this, either using inkscape or another program?
Many thanks in advance.
Answer
For simple tasks, the following should suffice:
Create the SVG as intended, and insert a dummy text at the desired location, which you can be certain to be unique like XYZwrzlprmftXYZ. The save the SVG, let’s say as dummy.svg
. As SVGs are XML-based you can easily search and replace in them, e.g., using sed
:
sed "s/XYZwrzlprmftXYZ/useful text/g" dummy.svg > useful.svg
This will create an SVG useful.svg
which is identical to your original SVG except that you now have “useful text” written in the desired location.
(For more complex tasks, you may want to use some more elaborate methods.)
No comments:
Post a Comment