private static void writeImage(Document document, int page, Resource destination,String format, int scale,
boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
BufferedImage bi=toBufferedImage(document,page,scale/100f,transparent);
Image img = new Image(bi);
img.writeOut(destination,format, overwrite, goodQuality?1f:0.5f);
}
private Document toDocument(byte[] input) throws PageException {