Batik svg conversion upon click event

230 views Asked by At

I have a simple webpage with an editable .svg image preview which includes some text, which the user can enter via a standard html form. When they're happy and want to continue to the next step, they click the save button. Theoretically the image would then be converted into a .jpg and saved to the server.

I have just come across Batik svg to image convertor and have successfully used it from the command line, as follows...

C:\inetpub\wwwroot\batik>java -jar batik-rasterizer.jar samples/input.svg -d orders -m image/jpeg -q 0.99 -dpi 150

My question is... can this batik tool be configured to take the svg, after an onclick event (button) and then convert and save it to a specified folder? In fact, is this the right tool at all?

Any ideas or direction would be greatly appreciated.

cheers Dec

1

There are 1 answers

0
Paul LeBeau On

It should work fine. You just need to deal with getting the text back to the server and updating a server copy of the SVG file. Then raster it with Batik. The first step would be best achieved with AJAX. How you do the server end depends on what sort of server you have running. If it is PHP, Python etc, the simplest way is probably to use the command line interface for Batik (as per your example). If you are running a Java web framework like Jetty or Tomcat, you could use the Batik library directly.