Archie Cobbs wrote:
Does using setAttributeNS() help ? It is recommended to always use the NS variant when creating elements and attributes. Attributes in batik need to be created with null (and not the string "null") namespace, otherwise batik doesn't draw them.I'm getting a weird problem when trying to use the SVGGraphics2D class. I'm creating an SVG document, and have an object that knows how to render onto a Graphics2D, whose image I want to include as a child node.
To do this I'm doing something like this:
// Create an embedded <svg> node imageNode = addElement(parent, "svg"); imageNode.setAttribute("viewBox", "0 0 " + width + " " + height); imageNode.setAttribute("overflow", "visible");
// Create a Graphics2D -> SVG encoder SVGGraphics2D g = new SVGGraphics2D(parent.getOwnerDocument());
// Render image, converting it to SVG renderer.render(g, new Rectangle(width, height));
// Get the embedded <svg> node imageNode = g.getRoot(imageNode);
In the case that the rendering is just lines, circles, etc. then everything works fine. But if the rendering includes an image, I'm getting this output in the resulting XML (edited for brevity):
<?xml version="1.0" encoding="UTF-8"?>
<svg overflow="visible" viewBox="0 0 595 842" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
...
<svg color-interpolation="auto" ... >
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g>
<image null:height="40" null:width="150" preserveAspectRatio="none" x="0" xlink:href="data:image/png;base64,iVBORw0KGgoAA ... "/>
...
Note the "null:" prefix on the height and width attributes.
How are you dumping the data from the document? Does the image display at all?
Has anyone seen anything weird like this?? I'm certainly not using the string "null" as a namespace prefix anywhere, and in any case it's Batik that adds those attributes. Another weird thing is: why only width and height? "preserveAspectRatio" comes out fine...
that is indeed very wierd. Are you adding those as well manually?
Regards Jorg
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
