
This was setup to allow any device on our company intranet to be able to print selected information from a nuBuilder record to a networked Zebra label printer.
Once you have a label template ready to use you need to get the code of the label in ZPL (Zebra Print Language) format. Label design programs should allow you to do this, I use Bartender 2016 and the print to file option, there is also the online Labelary ZPL Viewer which allows you to change the code and see the output directly.
So I have the following label Which has the following underlying ZPL code:
Code: Select all
^XA
^SZ2^JMA
^MCY^PMN
^PW626
~JSN
^JZY
^LH0,0^LRN
^XZ
^XA
^FT197,170
^CI0
^A0N,59,80^FDT0129^FS
^FT30,250
^A0N,42,64^FDPack Number:^FS
^FT440,256
^A0N,59,80^SN006,1,Y^FS
^FT37,94
^A0N,42,57^FDThingy Batch Number:^FS
^PQ1,0,1,Y
^XZ
Code: Select all
zpl_label
In this label there are three components I want to take the information from nuBuilder: the Thingy Batch Number (T0129 in the image), the Pack Number value (006 in the image), and the number of labels to print.
We will replace these with hash cookie values:
in the label code replace T0129 with
Code: Select all
'.$lot.'
Code: Select all
'.$startnum.'
Code: Select all
'.$numberlabels.'
Code: Select all
PQ'.$numberlabels.',0,1,Y
Code: Select all
$printer_ip = 192.168.30.1;
$printer_port = 9100';
$lot = '#tng_lot_number#';
$startnum = '#tng_batch_label_first#';
$numberlabels = '#tng_number_batch_labels#';
if(($conn = fsockopen($printer_ip,$printer_port,$errno,$errstr))===false){
echo 'Connection Failed' . $errno . $errstr;
}
$data = '
Code: Select all
';
#send request
$fput = fputs($conn, $data, strlen($data));
#close the connection
fclose($conn);
Next we need to put this code in the nuBuilder form for the end user to access.
In a Form, which has fields for tng_lot_number (the lot number), tng_batch_label_first (the number you want the Pack Number to start at), and tng_number_batch_labels (how many labels you want to print), fill the fields in as required.
Add a Print button for printing and change the Custom Code of the button to the following:
Code: Select all
nuRunPHPHidden('zpl_label',0);
var t = this;
nuHide(t.id);
Hope this may be of use to others. If using mulitple printers I can tell you how I've achieved it if you want to know.
Thanks,
Paul