ciao!
come da titolo, dovrei stampare una serie di immagini con java.
al momento, per capire il funzionamento, sto cercando di stamparne una sola.
questo il codice:
codice:
String imgTest = "/home/matte/Desktop/C180-001.jpg";
Image image = new Image(new File(imgTest).toURI().toString());
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null);
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable((graphics, pageFormat, pageIndex) -> {
int x = (int) Math.ceil(pageFormat.getImageableX());
int y = (int) Math.ceil(pageFormat.getImageableY());
if (pageIndex != 0) {
return Printable.NO_SUCH_PAGE;
}
graphics.drawImage(bufferedImage, x, y, bufferedImage.getWidth(), bufferedImage.getHeight(), null);
return Printable.PAGE_EXISTS;
});
try {
pj.print();
} catch (PrinterException e) {
GenericDialog.showDialog(e.getMessage(), Alert.AlertType.ERROR);
}
il problema è che esce il foglio bianco.
non va in eccezione, non ottengo errori, ecc.
dove sto sbagliando??