Hi David,

"David Thielen" <[EMAIL PROTECTED]> wrote on 10/26/2005 03:03:03 PM:

> I am trying to convert a wmf file to a png file. Since I am using batik, 
I am 
> assuming I have to go wmf -> svg -> png. Here is my code:
> 
> // wmf -> svg
> WMFTranscoder transcoder = new WMFTranscoder();
> TranscoderInput input = new TranscoderInput(new 
ByteArrayInputStream(wmf));
> ByteArrayOutputStream svg = new ByteArrayOutputStream();
> TranscoderOutput output = new TranscoderOutput(svg);
> transcoder.transcode(input, output);
> 
> // svg -> png
> ImageTranscoder it = new PNGTranscoder();
> ByteArrayOutputStream png = new ByteArrayOutputStream();
> it.transcode(new TranscoderInput(new 
ByteArrayInputStream(svg.toByteArray())),
> new TranscoderOutput(png));
> 
> The svg created appears correct (as much as I know). It does have <?xml 
> version="1.0" encoding="Cp1252"?> at the top.
> 
> When I run this I get:
> java.io.IOException: Invalid encoding name "Cp1252".

   I would suggest using an OutputStreamWriter and provide an explicit
charset encoding (probably "UTF-8").

> Question 1: Is this the most efficient way to do this?

   It seems likely. You could stream the two together rather
than writing to a byte array but the savings would probably be
minimal.
 
> Question 2: Why am I getting the exception?

   I think for some reason your default charset is
cp1252 (but I suspect the capitalization is wrong or something).

> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to