Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

print zpl from java

private static boolean printLabel(PrintService printService, String label) {
    if (printService == null || label == null) {
        System.err.println("[Print Label] print service or label is invalid.");
        return false;
    }
    String czas = new SimpleDateFormat("d MMMMM yyyy'r.' HH:mm s's.'").format(new Date());
    String command =  
            "N
"+
            "A50,50,0,2,2,2,N,""+label+""
"+
            "B50,100,0,1,2,2,170,B,""+label+""
"+
            "A50,310,0,3,1,1,N,""+czas+""
"+
            "P1
"
            ;
    
    byte[] data;
    data = command.getBytes(StandardCharsets.US_ASCII);
    Doc doc = new SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
    
    boolean result = false;
    try {
        printService.createPrintJob().print(doc, null);
        result = true;
    } catch (PrintException e) {
        e.printStackTrace();
    }
    return result;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #print #zpl #java
ADD COMMENT
Topic
Name
5+7 =