Thanks Fabian, I knew Batik had an answer! Eric
-----Original Message----- From: Fabian Unfried [mailto:[EMAIL PROTECTED] Sent: Friday, May 16, 2008 9:16 AM To: [email protected] Subject: Re: Problem wrting SVG to file Hi Eric, Try this: File f = new File("c:/test/slide11.svg"); SVGOMDocument docMap = (SVGOMDocument) chartDoc; docMap.createProcessingInstruction("xml", " version=\"1.0\" encoding=\"utf-8\""); TranscoderInput input = new TranscoderInput(docMap); OutputStreamWriter writer = null; try { //new OutputStreamWriter() writer = new OutputStreamWriter(new FileOutputStream(f), "utf-8"); SVGTranscoder svgt = new SVGTranscoder(); TranscoderOutput out = new TranscoderOutput(writer); svgt.addTranscodingHint(SVGTranscoder.KEY_XML_DECLARATION, new String("<?xml version=\"1.0\" encoding=\"utf-8\"?>")); svgt.addTranscodingHint(SVGTranscoder.KEY_DOCTYPE, SVGTranscoder.VALUE_DOCTYPE_CHANGE); svgt.addTranscodingHint(SVGTranscoder.KEY_FORMAT, SVGTranscoder.VALUE_FORMAT_ON); svgt.addTranscodingHint(SVGTranscoder.KEY_TABULATION_WIDTH, new Integer(5)); svgt.addTranscodingHint(SVGTranscoder.KEY_NEWLINE, SVGTranscoder.VALUE_NEWLINE_CR_LF); svgt.transcode(input, out); } catch(Exception e) { if(log.isErrorEnabled()) { log.error("runs into", e); } } I guess I have this from a batik example, but can't remember. Regards, Fabian > Hello: > > > > I have an SVGDocument (chartDoc) that I am trying to write to file. The > following code fails silently (an empty file is written). I use the > SVGDocument object for other purposes so I know it's good. Here's the > code: > > > > Source source = new DOMSource(chartDoc); > File file = new File("c:/test/slide11.svg"); > Result result = new StreamResult(file); > > Transformer xformer = TransformerFactory.newInstance().newTransformer(); > xformer.transform(source, result); > > > > > > My question is: Is there a way to accomplish this using Batik? > > > > Regards, > > Eric Hamacher > > > > ****************************** > > THIS EMAIL IS INTENDED ONLY FOR THE REVIEW OF THE ADDRESSEE(S), AND MAY > CONTAIN CONFIDENTIAL AND LEGALLY PRIVILEGED INFORMATION. INTERCEPTION, > COPYING, DISSEMINATION, OR OTHER USE BY OTHER THAN THE ADDRESSEE(S) IS > PROHIBITED AND MAY BE PENALIZED UNDER APPLICABLE PRIVACY LAWS. IF YOU > RECEIVED THIS EMAIL IN ERROR, PLEASE DELETE IT AND NOTIFY ME BY RETURN > EMAIL TO [EMAIL PROTECTED] ******************************* -- Fabian Unfried Software Engineer proveo GmbH Rossfelder Str. 65/5 | 74564 Crailsheim | Germany Phone: +49 7951 963610 | Fax: +49 7951 963650 mailto:[EMAIL PROTECTED] | http://www.proveo.de Management Board: Steffen Knödler | Harald Knödler | Holger Gerwin Registered Office: Ulm, HRB 721672 Disclaimer: This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please delete it and notify the sender immediately. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
