Hello, I am creating an application in java in which I command to print graphics to a printer. The problem I have is that if I do not set the printer as default in windows, it does not print to that printer.
I have seen that through the name it is sent to print to the printer, but I don't know how to implement it.
This is my code that I currently print with:
PrinterJob job = PrinterJob.getPrinterJob();
int numero = Integer.parseInt(SNumero.getValue().toString());
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(numero));
aset.add(new MediaPrintableArea(0, 0, 62, 29, MediaPrintableArea.MM));
aset.add(Chromaticity.COLOR);
aset.add(OrientationRequested.PORTRAIT);
job.setPrintable(new ObjetoDeImpresion());
job.setJobName("nombre_de_impresion");
try {
job.print(aset);
} catch (PrinterException ex) {
System.out.println(ex);
}
I try to send the name of the printer in the following way but it does not work:
String printerName = "Brother QL-800 (Copiar 1)";
aset.add(new PrinterName(printerName, null));
Does anyone know how to do it?