Hi,
I hope you can help me out with some problems I've run into using Batik. I've been Googling for this the last few days without coming up with a solution. I've also tried asking on some newsgroups but to no success.
I've recently found the batik and the VectorGraphics package from the freehep libraries <url:http://java.freehep.org/vectorgraphics/index.html> which mostly do exactly what I need; to load an SVG document and convert it to another vector graphics format (.cgm or .pdf). My problem is that freehep only use a standard Graphics2D-enabled component (i.e. JComponent) to be able to export. Batik, however, only outputs images to it's custom JSVGCanvas, which is not directly compatible with freehep. Using only a JComponent which I draw to myself using the paint() method I've gotten freehep export to work by using this syntax:
VectorGraphics vg = new PDFGraphics2D( new File("temp.pdf"), new Dimension(x,y)); vg.startExport(); super.print(vg); vg.endExport();
where 'super' points to the class extending JComponent.
I've also managed to draw an image based on an SVG file using the example on this page: <url:http://xml.apache.org/batik/svgcanvas.html>
Using that example I added another button and added this in the actionPerformed method for that button:
VectorGraphics vg = PDFGraphics2D( new File("test.pdf"), svgCanvas.getSize()); vg.startExport(); svgCanvas.print(vg); vg.endExport();
This syntax gives a couple of NullPointerExceptions.
I also tried to use the graphicsnode of the SVGCanvas by using this syntax:
svgCanvas.getGraphicsNode().paint(vg);
but this gives these two error messages:
PDFWriter: PDFRef 'Paint0' is used but not defined. PDFWriter: PDFRef 'Paint1' is used but not defined.
Do you have any experiences with these libraries, or other similar libraries that will do the same thing? I really need this converter to work as soon as possible. I'm kinda on a deadline here :)
---
Glenn Thomas Hvidsten
============= CORENA Norge AS ============= == Dyrmyrgt. 35, N-3611 Kongsberg, NORWAY == == Tlf: +47 3271 7234, Fax: +47 3271 7201 == == CORENA Home Page: http://www.corena.com ==
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]