Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > batik svg editing problem

Thread Tools

batik svg editing problem
Posts: n/a

I'm a beginner with batik library and I need to create a program that
would allow me to edit existing svg files and the save them.

The code that I have written so far doesn't seem to be working. My
program doesn't want to access my svg file, however there are no erros
when i execute it.

public void editSVG (String inputFilename) throws Exception {

DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
String svgURI = new File(inputFilename).toURL().toString();

SVGDocument doc;
try {
doc = (SVGDocument)impl.createDocument(svgURI, "svg", null);

// get the root element (the svg element)
Element svgRoot = doc.getDocumentElement();

// set the width and height attribute on the root svg element
svgRoot.setAttributeNS(null, "width", "400");
svgRoot.setAttributeNS(null, "height", "450");

// create the rectangle
Element rectangle = doc.createElementNS(svgNS, "rect");
rectangle.setAttributeNS(null, "x", "200");
rectangle.setAttributeNS(null, "y", "200");
rectangle.setAttributeNS(null, "width", "100");
rectangle.setAttributeNS(null, "height", "100");
rectangle.setAttributeNS(null, "fill", "red");

// attach the rectangle to the svg root element

} catch (Exception e){
System.out.println("Error: " + e);

inputFilename is a string with my svg filename (test.svg)

I would be really grateful if somebody could help.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
editing svg in batik problem milof83 Java 0 08-18-2006 10:20 AM
[SVG] probleme dessin d'images SVG avec Batik Mardagg Java 0 05-12-2006 02:13 PM
[SVG] problem with SVG image drawing with Batik Library Mardagg Java 0 05-12-2006 02:12 PM
Apache Batik - Question on editing SVG file and transform the graphics to other formats (e.g. JPG, PNG...) Brian K Java 0 10-12-2003 03:44 PM
Apache Batik - Question on editing SVG file and transform the graphics to other formats (e.g. JPG, PNG...) Brian K XML 0 10-12-2003 03:44 PM