zebra zpl print java

Solutions on MaxInterview for zebra zpl print java by the best coders in the world

showing results for - "zebra zpl print java"
Isabel
24 Jun 2019
1private static boolean printLabel(PrintService printService, String label) {
2    if (printService == null || label == null) {
3        System.err.println("[Print Label] print service or label is invalid.");
4        return false;
5    }
6    String czas = new SimpleDateFormat("d MMMMM yyyy'r.' HH:mm s's.'").format(new Date());
7    String command =  
8            "N\n"+
9            "A50,50,0,2,2,2,N,\""+label+"\"\n"+
10            "B50,100,0,1,2,2,170,B,\""+label+"\"\n"+
11            "A50,310,0,3,1,1,N,\""+czas+"\"\n"+
12            "P1\n"
13            ;
14    
15    byte[] data;
16    data = command.getBytes(StandardCharsets.US_ASCII);
17    Doc doc = new SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
18    
19    boolean result = false;
20    try {
21        printService.createPrintJob().print(doc, null);
22        result = true;
23    } catch (PrintException e) {
24        e.printStackTrace();
25    }
26    return result;
27}
28