Impression : sélection de l'imprimante à utiliser
Bonjour,
je m'essaye à l'impression avec les API sous Java 7.
Tout semble fonctionner pourtant, les documents sont toujours imprimés sur l'imprimante par défaut sous Windows, mais si dans la boite de dialogue (Dialog common) j'en choisi une autre.
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
/**
* Global printer
*/
private static final PrinterJob GLOBAL_PRINTER_JOB = PrinterJob.getPrinterJob();
// Get Attribut to print
final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
// Open dialog box
final boolean ok = GLOBAL_PRINTER_JOB.printDialog(aset);
// Get Job
final PrintService currentPrintService = GLOBAL_PRINTER_JOB.getPrintService();
final PrinterJob job = GLOBAL_PRINTER_JOB.getPrinterJob();
System.out.println(currentPrintService.getName());
job.print(aset); |
currentPrintService renvoie bien le bon nom d'imprimante mais l'impression part sur l'imprimante par défaut.
Ai-je oublié quelque chose ?
Merci