JPEGTranscoder jpegTranscoder = new JPEGTranscoder();
// Set the transcoding hints.
jpegTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.8));
// Create the transcoder input.
String inputString = getHeaders() + generateSVGString(); //svgDoc is set from generateSVGString()
TranscoderInput transcoderInput = new TranscoderInput(svgDoc);
Reader stringReader = new StringReader(inputString);
TranscoderInput transcoderInput2 = new TranscoderInput(stringReader);
// Create the transcoder output.
OutputStream osByteArray = new ByteArrayOutputStream();
TranscoderOutput transcoderOutput = new TranscoderOutput(osByteArray);
try {
jpegTranscoder.transcode(transcoderInput2, transcoderOutput);