Thanks for your answer. I tried your suggestion : I wrote :
 
org.apache.batik.dom.util.DOMUtilities.writeDocument(doc, new FileWriter("c:\\test.svg"));
 
where doc is the Document described in the example below.
But it doesn't work : the svg file created is empty. Do you know why ?
As I created the svg document by appending everything to the svgRoot element, I also tried as follow :
 
org.apache.batik.dom.util.DOMUtilities.writeDocument(svgRoot.getOwnerDocument(), new FileWriter("c:\\test.svg"));
 
but it failed too.
Do you know what to do ?
Thanks again.
Julie


"Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> a écrit :
In my application I simply used org.apache.batik.dom.util.DOMUtilities.writeDocument(SVGDocument, FileWriter);

Michael Bishop

________________________________

From: julie gautier [mailto:[EMAIL PROTECTED]
Sent: Thu 10/6/2005 7:52 AM
To: [email protected]
Subject: Write a svg document to a file


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 = ne w 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);
}


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();

The document test.svg is created but when I try to open it I have an error : the first line is :
"" instead of "" 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 Y ahoo! Messenger
Téléchargez le ici !
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici !

Reply via email to