Hi All, I have some very simple code, converting SVG to a PNG using batik.
This should be very simple to do, but for some reason there seems to be an error casting an SVGOMDocument to be SVGOMDocument (itself !!!) Any hints greatly appreciated ! Alan Here is my SVG: <svg height='600' width='800' version="1.1" xmlns=" http://www.w3.org/2000/svg"><desc></desc><defs></defs><a title="StartSymbol0"><circle stroke-width="5" font-size="91px" style="font-size: 91px; strok e-width: 5;" stroke="#000000" fill="#00ff00" r="20" cy="35" cx="35"/></a><circle stroke-width="4" font-size="93px" style="font-size: 93px; stroke-width: 4;" stroke="#000000" fill="#ff7f00" r="20" cy=" 222" cx="261"/><circle stroke-width="3" font-size="94px" style="font-size: 94px; stroke-width: 3;" stroke="#000000" fill="#ff7f00" r="10" cy="222" cx="261"/><path stroke-dasharray="15,5" stroke-width= "5" style="stroke-width: 5;" d="M56,35C148,35,148,222,240,222" stroke="#000000" fill="none"/></svg> Here is my code: ByteArrayInputStream bais = new ByteArrayInputStream(SVG.getBytes()); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); org.w3c.dom.Document doc = f.createDocument(null, bais); TranscoderInput input = new TranscoderInput( doc ); OutputStream ostream = new FileOutputStream( name + ".png" ); TranscoderOutput output = new TranscoderOutput( ostream ); PNGTranscoder t = new PNGTranscoder(); t.transcode(input, output); //Line 211 ostream.flush(); ostream.close(); Here is the Exception I get: java.lang.ClassCastException: org.apache.batik.dom.svg.SVGOMDocument cannot be cast to org.apache.batik.dom.svg.SVGOMDocument at org.apache.batik.bridge.BridgeContext.setDocument(BridgeContext.java:441) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:54) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at DiagramPersistanceServlet.writeImage(DiagramPersistanceServlet.java:211)