Expects Graphviz to be installed on the target system, e.g.:
- Ubuntu:
sudo apt install graphviz libgraphviz-dev - Fedora:
sudo dnf in graphviz graphviz-devel - etc.
<dependency>
<groupId>io.github.igrqb</groupId>
<artifactId>jnr-graphviz</artifactId>
<version>0.5.1</version>
</dependency>implementation 'io.github.igrqb:jnr-graphviz:0.5.1'For more dependency systems: https://mvnrepository.com/artifact/io.github.igrqb/jnr-graphviz/
import io.github.igrqb.jnr.graphviz.Graphviz;
String dot = "digraph { a -> b; b -> c }";
String svg = Graphviz.dotToSvg(dot);
// or directly to file
File svgFile = Graphviz.dotToSvg(dot, "/path/to/file.svg");
// Other export formats
OutputFormat format = OutputFormat.BMP;
// OutputFormat.JPG
// OutputFormat.PDF
// OutputFormat.PNG
// OutputFormat.SVG
// See OutputFormat.java for more
byte[] output = Graphviz.export(dot, format);