TranscoderException {
TranscoderInput input = new TranscoderInput(new StringReader(svg));
TranscoderOutput transOutput = new TranscoderOutput(stream);
// get right Transcoder, this depends on the mime
SVGAbstractTranscoder transcoder = SVGRasterizer.getTranscoder(mime);
if (width != null) {
/*
* If the raster image height is not provided (using the
* KEY_HEIGHT), the transcoder will compute the raster image height
* by keeping the aspect ratio of the SVG document.
*/
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH,
width);
}
if (width == null && scale != null && scale != 0.00) {
Float svgWidth = getWidthFromSvg(svg);
// calculate width from svg
if (svgWidth != null) {
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH,
svgWidth * scale);
}
}
transcoder.transcode(input, transOutput);
return stream;
}