You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Tonny Kohar <to...@kiyut.com> on 2015/05/19 07:05:27 UTC
Re: Loading SVG from StringBuffer or String
Hi,
> Now if i have the whole SVG content in the form of a
> String or a StringBuffer, how will I load it in to
> JSVGCanvas or into the applet?
You can do this by parsing the String/StringBuffer into SVG DOM
Document, and then past that SVG DOM Document into JSVGCanvas.
Here is the example
// parse String into DOM Document
StringReader reader = new StringReader(stringBuffer.toString());
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
// do not forget the URI, even it is fake eg: c://svg/sample.svg
// this is specially important if your doc reference other doc
// in relative URI
SVGDocument doc = f.createSVGDocument(uri,reader);
// set the doc to canvas
jsvgcanvas.setDocument(doc);
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org