We’re currently
using Batik and have encountered some issues when there are linefeeds inside a
<text> element. In the following example, extracted from a Visio SVG
export, shape5-12 renders properly and shape6-15 does not. Note that the only
difference is that the <text> element is spread across multiple lines in
shape6-15: <g id="shape5-12" v:mID="5" v:groupContext="shape" transform="translate(54,0)"> <title>Sheet.5</title> <desc>80%</desc> <v:textBlock v:margins="rect(0,0,0,0)"/> <v:textRect cx="13.5" cy="79.92" width="27" height="86.4"/> <rect x="0" y="36.72" width="27" height="86.4" class="st8"/> <text x="1.49" y="83.52" class="st9">80%</text> <text x="1.49" y="83.52" class="st9" v:langID="1033"><v:paragraph v:horizAlign="1"/><v:tabList/>80%</text> </g> <g id="shape6-15" v:mID="6" v:groupContext="shape" transform="translate(81,0)"> <title>Sheet.6</title> <desc>70%</desc> <v:textBlock v:margins="rect(0,0,0,0)"/> <v:textRect cx="13.5" cy="85.32" width="27" height="75.6"/> <rect x="0" y="47.52" width="27" height="75.6" class="st1"/> <text x="1.49" y="88.92" class="st2" v:langID="1033"> <v:paragraph v:horizAlign="1"/> <v:tabList/>70%</text> </g> The code that generates
the SVGDocument is basically:
XMLResourceDescriptor.setXMLParserClassName(“org.apache.xerces.parsers.SAXParser”);
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(“org.apache.xerces.parsers.SAXParser”); SVGDocument doc = (SVGDocument) f.createDocument(sURL); doc.normalize(); return doc; The core question is,
how can we arrange for the line feeds to be ignored in the text element? Adobe’s
viewer seems to do this fine, as does the SharpVectorGraphics library for .NET,
but Batik seems to have issues with it. Thanks! Rick Bullotta |
<<image001.gif>>