allora, per le dimensioni al momento hi fatto questo:
ho fatto qualche test, e non ho avuto problemi.codice:public class PrintImage implements Printable { private double x; private double y; private double width; private int orientation; private BufferedImage image; public PrintImage(PrinterJob printJob, BufferedImage image) { PageFormat pageFormat = printJob.defaultPage(); this.x = pageFormat.getImageableX(); this.y = pageFormat.getImageableY(); this.width = pageFormat.getImageableWidth(); this.orientation = pageFormat.getOrientation(); this.image = image; } @Override public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex == 0) { int pWidth = 0; int pHeight = 0; if (orientation == PageFormat.PORTRAIT) { pWidth = (int) Math.min(width, (double) image.getWidth()); pHeight = pWidth * image.getHeight() / image.getWidth(); } else { pHeight = (int) Math.min(width, (double) image.getHeight()); pWidth = pHeight * image.getWidth() / image.getHeight(); } graphics.drawImage(image, (int) x, (int) y, pWidth, pHeight, null); return PAGE_EXISTS; } else { return NO_SUCH_PAGE; } } }
ma sempre con una sola immagine.
per quanto riguarda la seconda domanda, una immagine a pagina.
non ho necessità di stampare varie immagini su una pagina!

Rispondi quotando
