Hi,
I use Batik to create a svg document and display it on a window. For that I use the above code :
public ActionForward doPerform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
...
/*creation of the svg document */
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
Element svgRoot = svgGenerator.getRoot();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
Element svgRoot = svgGenerator.getRoot();
/*insert svg into the document*/
...
/*send to output*/
java.io.OutputStream out = response.getOutputStream();
boolean useCSS = false;
Writer wout = new OutputStreamWriter(out, "iso-8859-1");
svgGenerator.stream(svgRoot, wout);
Writer wout = new OutputStreamWriter(out, "iso-8859-1");
svgGenerator.stream(svgRoot, wout);
}
This works fine. My problem is to send the "svgRoot" to a file on the server. Here is my code :
BufferedWriter bw = new BufferedWriter(new FileWriter("c:\\test.svg"));
svgGenerator.stream(svgRoot, bw);
bw.close();
svgGenerator.stream(svgRoot, bw);
bw.close();
The document test.svg is created but when I try to open it I have an error : the first line is :
"<?xml version="1.0"?>" instead of "<?xml version="1.0" encoding="iso-8859-1"?>" and I'm not able to open the file.
What should I do ?
Thanks in advance.
Julie
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici !
