xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@informatik.tu-darmstadt.de>
Subject export SVG to Graphics2D
Date Sat, 15 May 2004 21:47:09 GMT
Hi all,

I'm currently looking into jasperreports.sf.net to use SVG as 
intermediate graphics format when including images. Especially with 
rendered charts, a vector format is highly desirable.
Creating SVG documents for the charts is easy because of the great 
SVGGraphics2D provided by batik. This pretty much covers the graphics 
import.

However, for creating eg. PDF using itext, the report is drawn on a 
Graphics2D object provided by itext. Hence included images would need to 
be painted on the same Graphics2D object, actually on a given rectangle 
of the Graphics2D object.

I'm quite stuck at this point because I haven't successfully found a way 
to draw an SVG on a Graphics2D :-( I believe it should work along the 
lines of

    // create initial svg document for graphical object
    // included in report
    DOMImplementation domImpl =
       SVGDOMImplementation.getDOMImplementation();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    SVGDocument svgDocument = (SVGDocument)domImpl.createDocument(svgNS,
       "svg", null);
    SVGGraphics2D svgG2D = new SVGGraphics2D(svgDocument);

    ...
    // draw on the svgG2D
    ...

    // populate document
    Element root = svgDocument.getDocumentElement();
    svgG2D.getRoot(root);

    ...
    // store document somewhere
    // up to this point it looks OK because writing the XML
    // to a file and loading it with squiggle looks good
    ...

    // now, render included svg to provided Graphics2D
    // at given area ((x0,y0),(x1,y1))
    JSVGComponent svgComp = new JSVGComponent();
    svgComp.setDocument(svgDocument);
    svgComp.paint(g2d);

But it looks like I'm missing something here because I haven't been able 
to draw something this way :-( Besides: how to specify the placing of 
the output?

TIA
	Chris.

---------------------------------------------------------------------
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