Java - general

Print on a certain printer (without user intervention/dialogue)

javax.print.PrintService
The problem to print on a certain printer is to get the PrintService for this printer.
However, you can ask for a list with all printers and search for the desired printer:

\\

PrintService[] services = PrinterJob.lookupPrintServices();
for (PrintService ps : services) {
   if (ps.getName().equals("\\\\MyServer\\MyPrinter")) {
      print(ps);
      break;
   }
}
 
private void print(PrintService ps) {
   PrinterJob job = PrinterJob.getPrinterJob();
   job.setPrintService(ps);
   // Now print "normal".
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007