I use batik for drawing svg, and save it. That work.
But now i try to load my svg file and add somthing.
I use this fonction for load my svg file
private static SVGDocument loadSVGDocument(String uri) {
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
SVGDocument svgDocument = null;
try {
//svgDocument = factory.createSVGDocument(IMAGE_SVG);
svgDocument = factory.createSVGDocument(uri);
} catch (IOException e) {
System.out.println(e.getMessage());
}
return svgDocument;
}
and this for have SVGGraphics2D
SVGDocument svgDocument = loadSVGDocument(TEST_SVG);
SVGGraphics2D g = new SVGGraphics2D(svgDocument);
When i debug my SVGDocument have all children and attribut null And when i generate image, is empty and size is 400x400
Where is problem when i load my SVG file?
SVGGraphics2Dwith a document, then the document is the target for the painting operations. E.g. when you do something likeg.fillRect(10,10,20,30), then the document will contain a rectangle. But if the document already contains something, it will (probably) be overwritten. I don't know from the tip of my head how to use theSVGGraphicsto add something to an existing document. It should be possible, but I would have to try it out. - Marco13SVGGraphics) and save the result as SVG? - Marco13