Please excuse my ignorance but I really cannot get a grip of this. Here is my code, I can see svg, but no embed image. What is wrong? Thanks
canvas = new JSVGCanvas(); getContentPane().add(canvas); userAgent = new UserAgentAdapter(); ctx = new BridgeContext(userAgent); builder = new GVTBuilder(); try { // Parse the barChart.svg file into a Document. String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); URL url = new URL(getCodeBase(), "embedData.svg"); doc = f.createDocument(url.toString()); svg = doc.getDocumentElement(); NodeList l = svg.getElementsByTagName("image") ; for (int i = 0; i < l.getLength(); i++) { Element n = (Element)l.item(i) ; String image = n.getAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href"); String t = n.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE); int width = Integer.parseInt(t); int height = Integer.parseInt(n.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE)); String id = "image" + Integer.toString(i); // Create and initialize the new image element Element imageElement = doc.createElementNS(SVG_NAMESPACE_URI, SVG_IMAGE_TAG); imageElement.setAttributeNS(null, XMLConstants.XML_ID_ATTRIBUTE, id); imageElement.setAttributeNS(null, SVG_WIDTH_ATTRIBUTE, Integer.toString(width)); imageElement.setAttributeNS(null, SVG_HEIGHT_ATTRIBUTE, Integer.toString(height)); imageElement.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, XMLConstants.XLINK_HREF_QNAME, "data::image/PNG;base64," + base64Encode(image.getBytes())); doc.appendChild(imageElement); svg.removeChild(n); } } catch (Exception ex) { } -- View this message in context: http://batik.2283329.n4.nabble.com/How-to-render-embedded-png-tp4655236p4655244.html Sent from the Batik - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org