I am using Inkscape to export .svg files to LaTeX-PDF using the following command:

inkscape --without-gui --file="<file>.svg" --export-pdf="<file>.pdf" --export-latex

It generates a pdf document containing the "images" and a .pdf_tex document which is written in LaTeX, includes the .pdf file and fills it with the text contained in the .svg file. This works fine and most of the time the text is exactly at the position where it was placed inside the .svg file.

But sometimes the text is out of place, because obviously the fonts used are not the same. For example in one of my .svg files I have a box with text in it. When I export this file the text runs over the border of the box. I would like to know if it is possible to get rid of this problem for example by changing the font size via command line to something smaller.

EDIT: To provide you with a minimal working example: You can use PlantUML to generate an SVG that has this problem.


@startuml example.svg
class AClass{
    + void valueChanged(String key, String value);

You can generate this example .svg file using PlantUML with its -tsvg flag, like this:

java -jar "plantuml.jar" -tsvg example.txt
| improve this question | | | | |
  • 1
    If you think the fonts are not the same, then there is no other solution than to embed the fonts used: either as paths or as a font resource. If you are asking how to properly space a particular set of type, the naive way is to create a temp image with the type in a box with "auto width and height" and then measure the width and height. With that information, you can decide where the center should be, derive a top left origin from there, and place the text. If you have size constraints you must also decide how to trim the string – horatio Jul 10 '13 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.