Although I have a very simple question I have not found any good answer anywhere.
I would like to write a program (in Java) to create an SVG Image.
For example I would like to create an SVG file which would contain red circle with some set radius.
I would truly appreciate if someone could help me to find some tutorial for this kind of work. I spent a lot of time searching but I could not find anything. (Maybe I am using wrong keywords or something...)
Thank you
It depends what additional requirements you have. SVG files are XML files, so they are really just plain text files. You can create them with any of the standard IO methods. For example, this Java program satisfies your question:
public static void main(String[] args){
System.out.println("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"100\" height=\"100%\">");
System.out.println("<circle cx=\"50\" cy=\"50\" r=\"30\" fill=\"red\">");
System.out.println("</svg>");
}
Perhaps you want to create and manipulate DOM objects, similar to how you do it in Javascript. If that is the case, then you may want to try the Apache Batik library. You should be able to find plenty of tutorials on how to use that, both here on SO, and elsewhere on the web.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With