xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kai Grabfelder <Kai.Grabfel...@in-gmbh.de>
Subject RE: modify existing svg via SVGGraphics2D
Date Mon, 18 Apr 2005 12:46:13 GMT
thanks, this brought me to the rigth path.

just in case so. else bothers here the completer syntax:

//open existing svg file
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
String uri = "test.svg";
Document document = f.createDocument(uri);
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

//do some drawings with the svgGenerator object as stated in examples
[...]

//append the svgGenerator to the existing svg file
Element svgRoot = document.getDocumentElement();
svgRoot.appendChild(svgGenerator.getRoot());

//do transcoding and save png, jpg or wathever...
TranscoderInput input = new TranscoderInput(document);
...

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
Sent: Thursday, April 14, 2005 12:17 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: modify existing svg via SVGGraphics2D


Hi Kai,

Kai Grabfelder wrote:

> i'm trying to load an existing svg file and add some drawings to it, using
> the SVGGraphics2D class

> but i want to have an existing svg document as a template (i just want to
> draw on top of it) and so i tried
> 
> String parser = XMLResourceDescriptor.getXMLParserClassName();
> SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
> String uri = "test.svg";
> Document document = f.createDocument(uri);
> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
> //following some drawings on the svgGenerator object
> 
> but the resulting svg document does not consists of any elements present
in
> the test.svg input file. 

    This is what you want to do but the SVGGraphics2D only uses the
given Document as a factory it does not automatically append it's
output into the Document.  You would need to do this when the drawing is
done with something like:

     svgGenerator.getRoot(document.getDocumentElement());

> my question:
> 
> is it possible to draw on top of an existing svg file using SVGGraphics2D
> and if not how is it possible then? Do i have to use JSVGCanvas? (since i
> only need to create the svgs on the server side i thought this would not
be
> neccessary...)

    No you don't need to use the JSVGCanvas.


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

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


Mime
View raw message