将 SVG 1.1 转换为 1.0?

sdb*_*bbs 7 svg conversion

好的,所以使用 draw.io 桌面,我开始一个新的空白图,并仅绘制一个文本框,其中包含两行文本:

绘图

然后我执行文件/导出为/SVG...,选择缩放 100%,取消选中“包括我的图表的副本”,点击导出,另存为test.svg- 结果是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="81px" height="81px" viewBox="-0.5 -0.5 81 81" style="background-color: rgb(255, 255, 255);"><defs/><g><rect x="0" y="0" width="80" height="80" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 40px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Lucida Console; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">Hello<br />World!</div></div></div></foreignObject><text x="40" y="44" fill="#000000" font-family="Lucida Console" font-size="12px" text-anchor="middle">Hello...</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://desk.draw.io/support/solutions/articles/16000042487" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg>
Run Code Online (Sandbox Code Playgroud)

该文件在 Firefox 中可以正常打开:

Firefox 中的 svg

但是,如果我在 Inkscape 1.0.1 中打开它 - 文本不完整:

inkscape 中的 svg

...如果我使用rsvg-convert(来自 mingw-w64-x86_64-librsvg 2.50.1-1,在 Windows 10 中的 MSYS2/MINGW64 shell 中)将此SVG 转换为 PDF

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="81px" height="81px" viewBox="-0.5 -0.5 81 81" style="background-color: rgb(255, 255, 255);"><defs/><g><rect x="0" y="0" width="80" height="80" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 40px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Lucida Console; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">Hello<br />World!</div></div></div></foreignObject><text x="40" y="44" fill="#000000" font-family="Lucida Console" font-size="12px" text-anchor="middle">Hello...</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://desk.draw.io/support/solutions/articles/16000042487" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg>
Run Code Online (Sandbox Code Playgroud)

...然后我在 Firefox 中打开该 PDF,我的文本再次被破坏(如果我在 Adob​​e Reader 等中打开该 PDF 也是如此):

Firefox 中的 pdf

从上面的 SVG 内容中我们可以看到,这里的完整消息应该是“Viewer does not support full SVG 1.1”,并且链接到https://desk.draw.io/support/solutions/articles/16000042487,其中解释了这是由于自动换行造成的 - 我要么必须在 Draw.io 中关闭自动换行(我不希望这样做 - 我确实想绘制内部包含自动换行文本的框),或者导出为 PDF。

但是,我需要一个 .svg,它将进入 pandoc Markdown -> PDF 管道,并且由于它也使用 rsvg-convert,因此 .svg 图像最终会在文档中嵌入错误。

所以,我在想 - 我可以以某种方式将这种 SVG1.1 文件(带有自动换行文本)导出到 SVG1.0(每行自动换行文本有一个文本行)吗?如果 Inkscape 可以读取此文件,我可以使用它--export-plain-svg- 但如上所示,Inkscape 加载此 .svg 文件时也失败...

小智 3

我知道你在 5 个月前问过这个问题,但我可能会为其他有类似问题的人回答。

在draw.io 上,您可以使用打印功能来获取PDF。使用它,您可以根据图表的大小将纸张大小调整为 A0 或任何大小。

最后,您可以将 PDF 转换为 SVG 文件。我使用该链接: https: //image.online-convert.com/fr/convertir-en-svg,但您可以找到多个网站来执行此操作。

现在,您已在 svg 文件中获得了全文。我不知道你以后是否可以修改它,但是对于只想在PowerPoint上显示它的人来说,这是正确的。

希望它对某人有帮助!