How to convert SVG String to SVGDocument ?
August 23rd, 2007 | by Tonny Kohar |Just simply use StringReader to wrap your string and pass it to DocumentFactory as the example below
Note: this sample utilize Apache Batik
String yourString="<svg> ... </svg>"; StringReader reader = new StringReader(yourString); String uri = "set the document URI, so Batik will be able to resolve relative path"; try { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); doc = f.createSVGDocument(uri,reader); } catch (Exception ex) { // do your error handling here } finally { reader.close(); }










You must be logged in to post a comment.