xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabian Unfried <fabian.unfr...@proveo.de>
Subject Re: Problem wrting SVG to file
Date Fri, 16 May 2008 14:15:56 GMT
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 eric.hamacher@enetrix.com *******************************



-- 
Fabian Unfried
Software Engineer

proveo GmbH
Rossfelder Str. 65/5 | 74564 Crailsheim | Germany
Phone: +49 7951 963610 | Fax: +49 7951 963650
mailto:fabian.unfried@proveo.de | 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: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message