Batik and FreeHep

  • Thread starter Glenn Thomas Hvidsten
  • Start date
G

Glenn Thomas Hvidsten

Hi,

I've recently found the batik and freehep libraries 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.

Does anyone 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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top