Hello, I am creating a java application in which I send graphics to a printer. The problem I have is that if I do not put the printer as the default in windows, it does not send print to that printer.
I've seen that the name is sent to print to the printer, but I do not know how to implement it.
This is my code with which I currently print:
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?