fxsvgimage icon indicating copy to clipboard operation
fxsvgimage copied to clipboard

The converter from JavaFX to svg jar is not included in the distrib

Open hervegirod opened this issue 2 years ago • 6 comments

The converter from JavaFX to svg jar is not included in the distrib

hervegirod avatar Feb 25 '23 12:02 hervegirod

Hi, I have a question concerning this FX to svg converter. If I understand the title correctly the converter isn't working properly as of now? I would really like to use it to convert a rather complicated tree chart node to svg and I tried your code sample on how to do it but I am getting the following errors:

java.lang.NoClassDefFoundError: org/girod/javafx/svgimage/tosvg/SVGConverter Caused by: java.lang.ClassNotFoundException: org.girod.javafx.svgimage.tosvg.SVGConverter

and the same messages for ConverterParameters.

This is roughly how I am trying to implement your converter and I do not get any errors in intelliJ but when running the program I get the above mentioned errors.

    Node node = treeChart.getChart().getContent();

    double contentWidth = node.getBoundsInParent().getWidth() + ADDITIONAL_WIDTH;
    double contentHeight = node.getBoundsInParent().getHeight() + ADDITIONAL_HEIGHT;

    // taken from example usage of the converter from https://github.com/hervegirod/fxsvgimage
    ConverterParameters params = new ConverterParameters();
    params.width = contentWidth;
    params.height = contentHeight;
    SVGConverter converter = new SVGConverter();

    // Perform the conversion
    File svgFile = new File("mysample.svg");

    try {
        converter.convert(node, svgFile, params);
        System.out.println("SVG file created: " + svgFile.getAbsolutePath());
    } catch (Exception e) {
        e.printStackTrace();
    }

Do you think I am getting these errors because of the bug you issued or am I using this wrong?

thisissarah avatar Jul 17 '24 16:07 thisissarah

Hi, how are you setting up the classpath (manually or through maven)?

perNyfelt avatar Jul 22 '24 09:07 perNyfelt

I am using maven.

thisissarah avatar Jul 22 '24 10:07 thisissarah

This should work. Please create a reproducable example on github and I'd be happy to investigate.

perNyfelt avatar Jul 22 '24 11:07 perNyfelt

I tried your code and it works fine. My guess is that you did not set up the jitpack repository in your pom e.g:

  <repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
  </repositories>

.. you are not using the latest version:

    <dependency>
      <groupId>com.github.hervegirod</groupId>
      <artifactId>fxsvgimage</artifactId>
      <version>1.1</version>
    </dependency>

Full example here: fxsvgimage_issue39

perNyfelt avatar Jul 25 '24 09:07 perNyfelt

Hi, sorry for the late response and thank you very much for the example. I'll look into it and see what I did wrong in my code because I am pretty sure that I set everything up correctly in maven.

thisissarah avatar Jul 28 '24 20:07 thisissarah