Print Label from PHP on web server

Hi all,

I have a ZD420 printer I am developing an application for. I am using PHP for the server side code and html 5 for the front end. The printer is connected to the network through standard tcp/ip. I built 2 label templates using the Zebra Label designer and about 8 dynamic fields required. When I print to the printer from zebra designer or even from the printers web interface I get great results. What the client has asked is minimal configuration on their end. They want to plug in the printer; attach to their local network an then our application is to send the label to the printer along with the dynamic data and have the label print. They don't want to install the label manually on the printer or more than the standard zebra drivers on the web server which will communicate with the printer.

I am thinking I need to send ZPL right to the IP / port using standard socket commands. I looked at browser print as well as Link-OS but am a bit lost on the proper / best approach to do this.

I have the lbl files on the web server already and the drivers installed. I literally just want to send that lbl file to the printer along with the required data for the dynamic fields.

What is my best option to do this while meeting their PNP requirement as best as I can?

Any help appreciated!

Ron Craig
Just wanted to see if anyone

Just wanted to see if anyone has some input on this. Even if not completely specific to this use case.

Thanks!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Betsy Gamrat
I'm using GitHub - robgridley

I'm using GitHub - robgridley/zebra: PHP ZPL builder, image conversion and a basic client for network-connected Zebra label printe…

and it works great. 

I am only using the Client.php code - which a nice wrapper for TCP/IP sockets.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Chris Patrick
Idk if this is useful to

Idk if this is useful to anyone or not, but we use a php passthrough script to send zpl data as a string to the printer. The zpl is generated from the UPS shipping response and then just gets forwarded to the printer.


<?php

/*

* File Allows printing from web interface, simply connects to the Zebra Printer and then pumps data

* into it which gets printed out.

*/

$print_data = $_POST['zpl'];

// Open a telnet connection to the printer, then push all the data into it.

$print_data = str_replace('^XA^','^XA^^LT10^LS-5',$print_data); //this corrects the label top and label side properties to align the label correctly

try

{

    $fp=pfsockopen("192.168.1.80",9100);

    fputs($fp,$print_data);

    fclose($fp);

    echo 'Successfully Printed';

}

catch (Exception $e)

{

echo 'Print Failed.';

}

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ary Herijanto
Hello,I have Zebra GK420t,

Hello,

I have Zebra GK420t, how to print to print using PHP, my printer using USB port. I have tried using these codes as shown below but it just stop in the middle of printing process:

$myfile='label.zpl'; //file contain ZPL II codes

copy ($myfile,"//192.168.1.12/Zebra GK420t");// ip address defines my share-printer in windows

Thank you

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ary Herijanto
Hi Ron,This link might be
Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Esteban Chauque
Hi Ron

Hi all,
I' have a project for this problem

https://github.com/achauque/xPL-printserver

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments