6 Replies Latest reply on Jan 18, 2018 12:50 PM by Omar Barrera

    Hello World, using printer KR203 and JAVA

    Omar Barrera

      Hi, I try to send a Hello World to a thermal printer Zebra model KR203, these printers use the language KPL (Kiosk Printer Language), when printing a test page sale correctly but with my code stays in: "Printing ...", I can´t use the link-os-sdk because is not compatible with these type of printers this is my code:


          public void Print() {

              PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); //Here ZEBRA KR203 Is default printer

              PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();

              System.out.println("Default Printer :" + printService);

              String kplcommand = "<ESC>P<N1>\r\n"; // In this line try print test page

              byte[] by = kplcommand .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);



        • Re: Hello World, using printer KR203 and JAVA
          Samantha Corn

          Hi Omar,


          I believe it may not be printing because your KPL isn't correct. There should be a number instead of N1 in "<ESC>P<N1>\r\n". The KR203 Programming Guide contains the following table with possible values for N1.

          1 of 1 people found this helpful
            • Re: Hello World, using printer KR203 and JAVA
              Omar Barrera

              Hi Samantha, thanks for your answer I have update: "String kplcommand = "<ESC>P<N1>" by


              • String kplcommand = "<ESC>P<0>\r\n";
              • String kplcommand = "<ESC>P<0>";


              But nothing was printed, here I found that it is necessary to convert the code to hexadecimal format but I do not know what its equivalence is. Could you please help me please

                • Re: Hello World, using printer KR203 and JAVA
                  Manuel Caicedo-Rivera

                  Hi Omar,


                  The KR203 is a strictly graphics printer and need to be used with the KR203 Windows driver found on our Website, so it will not work with these commands if you are not using the driver, or the toolbox associated with it, please, check the link below for available resources.


                  KR203 Kiosk Printer Support & Downloads | Zebra





                  1 of 1 people found this helpful
                    • Re: Hello World, using printer KR203 and JAVA
                      Omar Barrera

                      Thanks for your answer, the main idea is to print using the java language not the toolbox, first I thought it was necessary to use the kpl commands to print later by try and failure I could print using these lines:


                          public void PrintTicketZ() {       

                              PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();


                              attributeSet.add(new Copies(1));

                              attributeSet.add(new JobName("PrintService", null));

                              attributeSet.add(new MediaPrintableArea(10, 0, 60, 400, MediaPrintableArea.MM));


                      PrinterJob pj = PrinterJob.getPrinterJob();

                              pj.setPrintable(new Printable() {

                                  public int print(Graphics g, PageFormat pf, int pageIndex) {

                                  if (pageIndex == 0) {

                                          int h = 100;

                                          int w = 100;

                                      String company="--";             

                                          try {

                                              double x = pf.getImageableX();

                                              double y = pf.getImageableY();

                                              Paper paper = pf.getPaper();

                                              pf.getPaper().setImageableArea(0, 0, paper.getWidth(), paper.getHeight());

                                              Graphics2D g2d = (Graphics2D) g;

                                              g2d.translate(x, y);


                                              g2d.setFont(new Font("TimesRoman", Font.PLAIN, 10));

                                              g2d.drawString("FOLIO: ", 105, 40);

                                              g2d.drawString("FECHA: ", 0, 60);

                                              g2d.drawString("HORA: ", 0, 75);

                                              g2d.drawString("N° EMPLEADO: " , 0, 100);

                                              g2d.drawString("EMPRESA: " , 0, 115);

                                              g2d.drawString("EMPLEADO: ", 0, 130);  

                                          } catch (WriterException e) {

                                              System.out.println("Error " + e);


                                          return Printable.PAGE_EXISTS;

                                      } else {

                                          return Printable.NO_SUCH_PAGE;





                      PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();

                              if (defaultPrintService != null) {


                      String print_default = defaultPrintService.getName();





                                      PrintServiceAttributeSet printServiceAttributeSet = defaultPrintService.getAttributes();

                                      String trabajo = printServiceAttributeSet.get(QueuedJobCount.class).toString();

                                      int trabajos = Integer.parseInt(trabajo);



                                  } catch (PrinterException pe) {

                      log.error("Error al imprimir: " + pe);