> From: Stevenson, Chris (SSABSA) [mailto:[EMAIL PROTECTED]]
>
> How can I set the viewBox attribute using the 
> SVGGraphics2D classes?
> 
> I want to set the viewBox on an SVG created with the 
> SVGGraphics2D class, so that the image will scale.
> 
> I have tried the following:
> 
>         // Create an instance of org.w3c.dom.Document
>         Document document = domImpl.createDocument( null, 
> "svg", null);
> 
>         //This viewBox attribute never appears.
>         Element el = document.getDocumentElement();
>         el.setAttributeNS(null, "viewBox", "0, 0, 600, 400" );
> 
>         System.out.println( 
> document.getDocumentElement().getAttribute(
> "viewBox" ) );
> 
>         // Create an instance of the SVG Generator
>         SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
> 
> but it doesn't work - the attribute disappears.

Chris,

As far as I'm aware, the root element gets overwritten if you use the
document as DOM factory for your SVGGraphics2D instance. I think you might
have better luck if you set the attribute on the root of the tree *after*
generation by svgGenerator. Info in the tutorial on "Customizing the
generated SVG style" (http://xml.apache.org/batik/svggen.html#custom) may be
of interest to you.

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to