简体   繁体   English

graphviz:如果 output 是 SVG,则不会插入 SVG 图像的节点

[英]graphviz: Nodes of SVG images do not get inserted if output is SVG

I created a small SVG image.我创建了一个小的 SVG 图像。 It renders just fine in Firefox.它在 Firefox 中渲染得很好。 Then I created a graphviz file which contained (among other things):然后我创建了一个 graphviz 文件,其中包含(除其他外):

  mynote [label="", image="mybox.svg"];

Then I ran this on that:然后我在上面运行了这个:

  $ dot -Tsvg:svg:core infile.dot -o outfile.svg

I get the following:我得到以下信息:

Warning: "mybox.svg" was not found as a file or as a shape library member
Warning: No or improper shapefile="mybox.svg" for node "mynote"

PS: with png files work normally. PS:使用 png 文件可以正常工作。

I've been struggling with this exact problem for a day or so, thought I'd share the solution I found.我已经为这个确切的问题苦苦挣扎了一天左右,以为我会分享我找到的解决方案。

I was trying to use fontawesome icons inside my graphviz graph.我试图在我的 graphviz 图形中使用 fontawesome 图标。

The svgs you get form fontawesome are not propperly formated according to the xml standard.您从 fontawesome 中获得的 svgs 没有根据 xml 标准正确格式化。 They are lacking the xml declaration.他们缺少 xml 声明。

Making sure the svg you are trying to import starts with the following line resolved the issue for me.确保您尝试导入的 svg 以以下行开头为我解决了这个问题。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

I had the same issue.我遇到过同样的问题。 The svg file was properly constructed, but caused these errors. svg 文件构造正确,但导致了这些错误。

The svg was stored in UTF-8 with BOM. svg 与 BOM 一起存储在 UTF-8 中。 The error disappeared when storing it without BOM.在没有 BOM 的情况下存储它时错误消失了。 No other changes were required.无需进行其他更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM