decodePdf.openPdfArray(baos.toByteArray());
/** get page 1 as an image */
BufferedImage img = decodePdf.getPageAsImage(1);
/** close the pdf file */
decodePdf.closePdfFile();
baos.reset();
ImageIO.write(img, format.getExtension(), baos);
} catch (PdfException e) {
throw new PrintingException(e, PrintingException.DOCUMENT_RENDER_PROBLEM);
}