I’m looking to move from an existing database web app,which uses php/JS/SQL, to ERPNext which is going well but I’,unsure where to start with label printing directly to Zebra printers.
Currently this is achieved with no locally installed devices drivers or QZ tray middle apps required on the users’ device.
The information is taken from the db record the user is accessing via JS, and passed to a php procedure, which sends the ZPL label information via IP address to the printer. All on a simple button press and works well.
(Admittedly no error handling or user feedback but the user is usually nearby to see if the labels have printed).
I’ve searched on the forum and tried various bits of custom formats for Zebra ZPL printing.
I want to continue to not have to install additional software on end user devices, so no solutions with drivers or QZ software are going to work.
What is the best way to go about this?
Do I need to install the Zebra printers on ERPNext? Then setup something via raw printing?
Do I create a server side script (API looks best?) from which I can pass variables from the record being viewed to the script and send to the Zebra printer? If so how do I use a button to activate the server script?
Just starting out in python, so all very new to me. Also starting out with ERPNext and trying to get my head around the whole setup.
Any info or suggestions gratefully received.
Thanks,
Paul
You may have to use a library on your ERPNext server and install using pip install zebra. Then you can import the zebra library into your python files and use it.
I’ve seen a few on pip but they are more to do with generating ZPL label code, which I already have, so it is not a problem for me.
Zebra themselves have ther following code to open a socket and send the label code.
import socket
mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host = "10.80.209.106"
port = 9100
try:
mysocket.connect((host, port)) #connecting to host
mysocket.send(b"^XA^A0N,50,50^FO50,50^FDSocket Test^FS^XZ")#using bytes
mysocket.close () #closing connection
except:
print("Error with the connection")
Question is where does it belong and how to insert variables from the record to print? The label code is between ^XA and ^XZ, so they would be inserted there.
Then make that code accessible to print?
Thanks for how to active the server script, couldn’t easily find it in the docs.
If I remember correctly JS can’t open the required sockets, a security feature by design to prevent anything nefarious client side being executed on the server. That’s why I was looking to use a server script instead.
Out of curiousity do you know why/how the network print feature is meant to work? I’ve sent up a network printer on my local install but when I try to print ERPNext default to the browser print manager, and also the report looks nothing like the format in ERPNext’s Print Preview.