【发布时间】:2016-12-19 18:47:09
【问题描述】:
我刚刚用python程序生成了一个SVG文件:out2.svg
所有文件都在这里:https://github.com/jeremy886/svg_crossworder
当我使用 Adobe Illustrator 时,我可以查看它并将其正确导出为 PNG。但是如果我在 Firefox 或 Finder 等浏览器中打开它,它就无法正确显示(只有图片的一角)。愿望文件是这样的:out2-adobe.png
我还想通过像 CairoSVG 这样的程序将 SVG 文件转换为 PNG(或任何图像格式可以被枕头和 reportlab 读取),而不是手动使用 Adobe Illustrator。
如何修复 SVG 文件以实现这一目标? 我从这个程序生成了 SVG 文件:make_crossword.py
我怀疑我需要修复这些行:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 612 792" style="enable-background:new 0 0 612 792;" xml:space="preserve">
<style type="text/css">
.st0{stroke:#000000;stroke-width:2.2201;stroke-linecap:square;}
.st1{fill:#FFFFFF;stroke:#000000;stroke-width:2.2201;stroke-linecap:square;}
.st2{font-family:'CourierNewPSMT';}
.st3{font-size:64px;}
.st4{font-family:'TimesNewRomanPSMT';}
.st5{font-size:36px;}
.st6{enable-background:new ;}
</style>
<g>
<polyline class="st0" points="0,0 0,100 100,100 100,0 "/>
<polygon class="st0" points="0,0 0,100 100,100 100,0 "/>
</g>
<g>
<polyline class="st0" points="100,0 100,100 200,100 200,0 "/>
<polygon class="st0" points="100,0 100,100 200,100 200,0 "/>
</g>
[delete...]
【问题讨论】: