xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vincent Hardy <vincent.ha...@sun.com>
Subject Re: How to add an element before generating the SVG image?
Date Wed, 22 Jan 2003 19:54:26 GMT
Hello Karen,

After you get the root, you should use one of the following two methods 
to write out your content:

stream(Element svgRoot, java.io.Writer writer, boolean useCss)
or
stream(Element svgRoot, java.io.Writer writer)

By default, getRoot causes the SVGGraphics2D to reset its content, so if 
you stream without passing the previously retrieved root, SVGGraphics2D 
just streams out the new, empty content.

Vincent.

Karen Chen wrote:
> Hi,
> I would like to add some new elements (<title> and 
> <description>)before I generate the xml file using the SVGGraphics2D.
> A desired output would be:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 
> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
> <svg >
> <title>Title for the generated image</title>
> <desc>Image description</desc>
> <!--Generated by the Batik Graphics2D SVG Generator-->
>     <defs id="genericDefs" />
>         <g />
>         //... generated image contents
>         <g />
> </svg>
> I  have tried using the getRoot() method from the SVGGraphics2D class, 
> added some elements and tried to generate the svg file, but the codes to 
> describe the images just disappeared and became empty tags. I haven't 
> got any idea how to resolve the problem and why it happens this way. Can 
> someone who has solved this problem before provide some help? 
>  
> The resultant code i got after manipulating the Element I get from the 
> getRoot() method was:
>  
> <?xml version="1.0" encoding="UTF-8"?>
>  
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 
> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
> <svg style="fill-opacity:1; color-rendering:auto; 
> color-interpolation:auto; text-rendering:auto; stroke:black; 
> stroke-linecap:square; stroke-miterlimit:10; shape-rendering:auto; 
> stroke-opacity:1; fill:black; stroke-dasharray:none; font-weight:normal; 
> stroke-width:1; font-family:&apos;sansserif&apos;; font-style:normal; 
> stroke-linejoin:miter; font-size:12; stroke-dashoffset:0; 
> image-rendering:auto;" xmlns="http://www.w3.org/2000/svg" width="591" 
> xmlns:xlink="http://www.w3.org/1999/xlink" height="498">
>   <!--Generated by the Batik Graphics2D SVG Generator-->
>   <defs id="genericDefs" />
>   <g />
> </svg>
> Thanks in advance!
>  
> Karen Chen



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message