Print EPL code with javascript

4

I'm doing some testing with the Zebra GC420T printer using the EPL language to generate text and barcode.

How can I use javascript to send the printer the following code?

N
q812
S2
A50,0,0,1,1,1,N,"Example 1 0123456789"
A50,50,0,2,1,1,N,"Example 2 0123456789"
A50,100,0,3,1,1,N,"Example 3 0123456789"
A50,150,0,4,1,1,N,"Example 4 0123456789"
A50,200,0,5,1,1,N,"EXAMPLE 5 0123456789"
A50,300,0,3,2,2,R,"Example 6 0123456789"
LO25,600,750,20
B50,800,0,3,3,7,200,B,"998152-001"
P1
    
asked by anonymous 06.04.2015 / 17:33

1 answer

3

JavaScript does not have direct access to the user's printer, so it is necessary to use another medium for this impression. One way to do this using javascript is with the jzebra applet

Code sample:

<input type=button onClick="print()" value="Print">
<applet id="qz" name="QZ Print Plugin" code="qz.PrintApplet.class" archive="./qz-print.jar" width="100" height="100">
      <param name="printer" value="zebra">
</applet>

<script>
      function print() {
         var qz = document.getElementById('qz');
         qz.append('A37,503,0,1,2,3,N,PRINTED USING QZ-PRINT\n');
         // ZPLII
         // qz.append('^XA^FO50,50^ADN,36,20^FDPRINTED USING QZ-PRINT^FS^XZ');  
         qz.print();
      }
</script>

Follow the implementation library link for it: Web Tutorial Applet jzebra .

There are other ways to achieve the expected, for example, I already did a program in C # that was invoked when the user entered a URI PRINTAR://A37,503,1,0,0,N,XXX receiving the parameters for printing by it.

In order for the program to be invoked in this way, it created keys in the user registry during installation, such as the following example:

HKEY_CLASSES_ROOT
   PRINTAR
      (Default) = "URL:Print Protocol"
      URL Protocol = ""
      DefaultIcon
         (Default) = "printar.exe,1"
      shell
         open
            command
               (Default) = "C:\Program Files\Print\printar.exe" "%1"

and was then invoked by using window.open('PRINTAR://XXXXXX'); in javascript.

    
06.04.2015 / 19:28