0

On Windows 10, I use Graphviz to render a dot file. This dot file has nodes that contain SVG images.

C:\something\dot.exe -Tpdf -o "out" "in.dot"

dotfile:

digraph G {
N1 [label = < <table ><tr><td><img src="C:\abs\path\to\img.svg" /></td></tr></table> >];
}

The resulting file displays the nodes, but the SVG images are missing. Graphviz displays a message:

Warning: No loadimage plugin for "svg:cairo"

I believe the dot file itself is correct, as switching to -Tsvg works without warnings and the resulting file has the SVG images as it should. It also works (with -Tpng, -Tpdf and -Tsvg) if the embedded images are PNG instead of SVG.

From the warning, I suppose Graphviz is missing "librsvg". I thought Graphviz had this already embedded. This is the output of dot -v:

dot - graphviz version 7.0.3 (20221126.0506)
libdir = "C:\dev_bin\Graphviz\bin"
Activated plugin library: gvplugin_dot_layout.dll
Using layout: dot:dot_layout
Activated plugin library: gvplugin_core.dll
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
        C:\dev_bin\Graphviz\bin\config6
                was successfully loaded.
    render      :  cairo dot dot_json fig gdiplus json json0 map mp pic pov ps svg tk visio vml xdot xdot_json
    layout      :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
    textlayout  :  textlayout
    device      :  bmp canon cmap cmapx cmapx_np dot dot_json emf emfplus eps fig gif gv imap imap_np ismap jpe jpeg jpg json json0 metafile mp pdf pic plain plain-ext png pov ps ps2 svg tif tiff tk vdx vml xdot xdot1.2 xdot1.4 xdot_json
    loadimage   :  (lib) bmp eps gif jpe jpeg jpg png ps svg

It has loadimage: svg. Is this insufficient for reading SVGs in -Tpdf?

I could not find a way to install or download librsvg separately for Windows.


Below is the SVG file generated from the above dotfile. It correctly links to the embedded SVG file.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.3 (20221126.0506)
 -->
<!-- Title: G Pages: 1 -->
<svg width="243pt" height="231pt"
 viewBox="0.00 0.00 242.76 231.45" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 227.45)">
<title>G</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-227.45 238.76,-227.45 238.76,4 -4,4"/>
<!-- N1 -->
<g id="node1" class="node">
<title>N1</title>
<ellipse fill="none" stroke="black" cx="117.38" cy="-111.72" rx="117.26" ry="111.95"/>
<polygon fill="none" stroke="black" points="45.38,-39.72 45.38,-183.72 189.38,-183.72 189.38,-39.72 45.38,-39.72"/>
<image xlink:href="C:\abs\path\to\image.svg" width="138px" height="138px" preserveAspectRatio="xMinYMin meet" x="48.3797" y="-180.723"/>
<polygon fill="none" stroke="black" points="42.38,-36.72 42.38,-186.72 192.38,-186.72 192.38,-36.72 42.38,-36.72"/>
</g>
</g>
</svg>

The embedded SVG file (C:\abs\path\to\image.svg) is in the same directory as the dotfile.

mafu
  • 31,798
  • 42
  • 154
  • 247

0 Answers0