Print EPL code with javascript

Asked

Viewed 1,820 times

5

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

How can I javascript the printer print 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

1 answer

3


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

Code example:

<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 link to the implementation library: Tutorial Web Applet jzebra.

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

In order for the program to be invoked in this way, it created keys in the user’s registry during its 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 the use of window.open('PRINTAR://XXXXXX'); in javascript.

  • So the applet seems to be very interesting, I did some tests but I did not get many results, it sends to the printer and in the status is marked as "printing" http://demo.qzindustries.com/

  • I managed to print a test with the applet, now I just need to adapt to my code :D

  • @silvioAny great, sorry I hadn’t seen your previous comment, what was the problem? Comment here that then I add in the answer!

  • I wasn’t using the plugin properly. But then I followed this tutorial https://code.google.com/p/jzebra/wiki/TutorialWebApplet and I got it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.