I am trying to add the height and width attributes to the <svg> tag in my svg
document that I am generating from SVG2DGraphics but am not having much
success, here is the code I am trying:
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
Document document = domImpl.createDocument(null, "svg", null);
// get the root element (the svg element)
Element svgRoot = document.getDocumentElement();
// set the width and height attribute on the svg root element
svgRoot.setAttributeNS(null, "width", "400");
svgRoot.setAttributeNS(null, "height", "450");
//Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
BufferedImage image = ImageIO.read(new File("C:/simple circle.jpg"));
boolean result = svgGenerator.drawImage(image, 0, 0, null);
Writer out = new OutputStreamWriter(new FileOutputStream("C:/testing1.svg"),
"UTF-8");
svgGenerator.stream(out, true);
out.close();
I also tried getting the root from the svgGenerator object:
Element root = svgGenerator.getRoot();
root.setAttributeNS(null, "width", "400");
root.setAttributeNS(null, "height", "450");
And this didn't work either.
Any help in setting these attributes would be greatly appreciated. The Glips
editor won't read an svg file without these attributes set so I do need
them.
Thanks.
Victoria.
--
View this message in context:
http://www.nabble.com/Can%27t-add-height-width-attribs-to-%3Csvg%3E-tag-when-using-SVG2DGraphics-tf2500244.html#a6969860
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]