Batik and FreeHep

Discussion in 'Java' started by Glenn Thomas Hvidsten, Feb 28, 2005.

  1. 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 :)
    Glenn Thomas Hvidsten, Feb 28, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lordy
    Replies:
    1
    Views:
    1,147
    Lordy
    Sep 13, 2003
  2. Brian K
    Replies:
    0
    Views:
    827
    Brian K
    Oct 12, 2003
  3. Shripathi Kamath

    Question on JFreeChart and Batik

    Shripathi Kamath, Nov 26, 2003, in forum: Java
    Replies:
    0
    Views:
    2,305
    Shripathi Kamath
    Nov 26, 2003
  4. Benny
    Replies:
    0
    Views:
    1,160
    Benny
    Jul 10, 2003
  5. Brian K
    Replies:
    0
    Views:
    625
    Brian K
    Oct 12, 2003
Loading...

Share This Page