Zebra Printer print script example using ZPL
There is work in the office that uses the ZT230 and GX430t zebra printers.
We can print directly by selecting the zebra printer that has been installed, but if we need a certain format, it is better to use ZPL or Zebra Printing Language.
Before printing directly on paper, in the testing process, the author usually uses a preview from the website http://labelary.com/viewer.html, in this way to save paper because there is no need to print directly to paper many times.
Layout Paper Configuration
Setting the canvas size according to the size of the sticker paper used, for example the paper that the author uses is 10cmx5cm, then the canvas configuration settings are as follows: Print Density: 12 dpm (300 dpi) Label Size: 10 x 5 cmZPL Script Example
Suppose we want to make a printout with a barcode format according to the following image The following is an example of a ZPL script:^XA
^CFA,30
^FO50,130^FDName^FS
^FO50,170^FDAlamat:^FS
^FO50,210^FDKTP:^FS
^FO50,250^FDMobile:^FS
^CFA,30
^FO200,130^FDJohn Doe^FS
^FO200,170^FDJln Jend. Sudirman^FS
^FO200,210^FD123456789^FS
^FO200,250^FD12345678^FS
^FO600,170^FDNo^FS
^FO700,170^FDRT^FS
^FO600,270^FDRW^FS
^FO700,270^FDNo^FS
^FO590,310^FD1^FS
^FO710,310^FD2^FS
^FO710,210^FD3^FS
^FX Third section with barcode.
^A1N,30,22^BY2,2,70
^FO230,20^BC^FD123456789^FS
^CFB,30
^FO600,210^FD4^FS^XZ
Explanation of the script:
Lines no. 2 – 6 for setting the font size and placing the labels Name, Address, KTP, and Mobile with coordinates x 50, 130
^CFA,30
^FO50,130^FDName^FS
^FO50,170^FDAlamat:^FS
^FO50,210^FDKTP:^FS
^FO50,250^FDMobile:^FS
Rows 7 – 18 are the same as rows no. 2 – 6
^CFA,30
^FO200,130^FDJohn Doe^FS
^FO200,170^FDJln Jend. Sudirman^FS
^FO200,210^FD123456789^FS
^FO200,250^FD12345678^FS
^FO600,170^FDNo^FS
^FO700,170^FDRT^FS
^FO600,270^FDRW^FS
^FO700,270^FDNo^FS
^FO590,310^FD1^FS
^FO710,310^FD2^FS
^FO710,210^FD3^FS
Line 21 is for setting the barcode
^A1N,30,22^BY2,2,70
while line 22 is a barcode printer with position coordinates of position 230.20 and data 123456789
^FO230,20^BC^FD123456789^FS
Lines 24-25 are for setting the font size to be bigger and bold
^CFB,30
^FO600,210^FD4^FS^XZ
Connection Type
There are 2 type connection to print- USB connection – We have to install the zebra printer driver, then if we print from the web we must also install the Browser Printer tools software
- Network connection – for this connection we do not need to install the driver, the zebra printer is built in its own local server.
Example Source Code printing with Zebra
The following is a sample source code / printing script for the zebra printer, which can be downloaded at the link below https://github.com/rudiahmad/zebra-printer.git There are 3 folders, namely:- print-lwt-php -> Script print via PHP
- print-using-direct-ip -> Script print via direct ip with javascript
- zebra-browser-print-js-v30216 -> Script library from zebra using browser print tools