}
private static byte[] getPDFByteArray(final Document document, final int width)
{
// Create a pdf transcoder
final PDFTranscoder t = new PDFTranscoder();
t.addTranscodingHint(PDFTranscoder.KEY_AUTO_FONTS, false);
t.addTranscodingHint(PDFTranscoder.KEY_WIDTH, new Float(width));
TranscoderInput input = new TranscoderInput(document);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final TranscoderOutput output = new TranscoderOutput(baos);
// Save the image.
try {
t.transcode(input, output);
} catch (TranscoderException ex) {
log.fatal("Exception encountered " + ex, ex);
}
return baos.toByteArray();
}