I try to send a Hello World to a Zebra thermal printer model KR203 , these printers use the language KPL (Kiosk Printer Language), when printing a test page it goes out correctly but with my code it stays in: "Printing ...".
This is my code:
public void Imprimir() {
PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
System.out.println("Default" + printService);
String zplCommand = "^XA\n"
+ "^FO10,0^ARN,11,7^FD SOME TEXT ^FS\n"
+ "^FO300,0^ARN,11,7^FD SOME VALUE ^FS\n"
+ "^FO10,35^ARN,11,7^FD SOME TEXT ^FS\n"
+ "^FO300,35^ARN,11,7^FD SOME VALUE ^FS\n"
+ "^FO10,70^ARN,11,7^FD SOME CODE ^FS\n"
+ "^FO10,115^ARN,11,7^BCN,60,Y,Y,N^FD 23749237439827 ^FS\n"
+ "^XZ";
byte[] by = zplCommand.getBytes();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(by, flavor, null);
DocPrintJob job = printService.createPrintJob();
try {
job.print(doc, null);
//job.print(doc, attributeSet);
} catch (PrintException e) {
System.out.println("e " + e);
}
}
Note: It's a desktop application