Python CLI tool that allows to scan-to-print from barcode to zebra label printer.
When you run the application, it will enter an infinite loop and prompt you for an input (which can correspond to any key in the data.json file). Upon entering or scanning the input, the application will send a ZPL code to the designated printer IP using a socket request. It will then display the success or error status (only network status, if the application can reach the IP address, it will be considered successful, regardless of the printer's status) of the printing process and will request another input from you.
You can only print one at a time. For batch printing, I use a completely different custom application. If desired, you can modify the application to loop through all data in data.json and apply socket_request() to each IP.
Here's how I am using the application: I have barcodes on each printer/desk, and I am utilizing a Windows tablet with a built-in Zebra barcode scanner (Zebra ET5).
Cloning the repo
git clone https://github.com/angelside/ricoh-supply-cli-py.git scan-to-print
cd scan-to-print
Use the package manager poetry to install. Run the below command inside the project directory.
poetry install
Configuration files
- data.json (Not in git repo)
- label.txt (Current file has a small label)
data.json sample
"Barcode" : "Printer IP address"
{
"Desk-1": "192.168.0.2",
"Desk-2": "192.168.0.3",
"Desk-3": "192.168.0.4",
}
label.txt samples
small label
^XA
^LT0
^LH0,0
^JMA
~SD15
^FO0,0^GB530,77,55^FS
^CI28
^PA0,1,1,0
^FT15,115^A0N,25,20^FB520,1,13,L^FH\^CI28^FD$location^FS^CI27
^FT355,115^A0N,25,18^FB520,1,13,L^FH\^CI28^FD$time^FS^CI27
^FT0,175^A0N,25,20^FB520,1,10,C^FH\^CI28^FD$message^FS^CI27
^XZ
big label
^XA
^LT0
^LH0,0
^JMA
~SD15
^CI28
^PA0,1,1,0
^FO1,1^GB810,164,148^FS
^FT4,347^A0N,72,71^FB808,1,18,C^FH\^CI28^FD$location^FS^CI27
^FT4,512^A0N,51,51^FB808,1,13,C^FH\^CI28^FD$message^FS^CI27
^FT120,657^A0N,25,25^FH\^CI28^FD$time^FS^CI27
^XZ
- You can create yor own zpl template code as you wish. Yo can preview zpl templates from Labelary Online ZPL Viewer.
$location This is the "key" in the json file
$time Current time
$message Opps, this is hardcoded in the main.py file (IT zebra printer quality test)
Without build, just run the python file.
python main.py
With build (tested only in Windows) You can build a binary file, and use it.
pip install -U pyinstaller
pyinstaller --noconfirm --onefile --console --icon "./printer.ico" --name "scan-to-print" "./main.py"
./scan-to-print.exe
> py .\main.py
=== Scan to Print ===
Location:
- Simple label with full black top.
- Report missing config files (data.json, label.txt).
- Achieve correct CLI colors in Windows Command Prompt using the "colorama" package.
- Ctrl+C for exit
- ZD 620
- ZD 621
- GK 420d
Before contributing issues or pull requests, could you review the Contributing Guidelines first?
Feel free to open an issue.
💙 If you like this project, give it a ⭐ and share it with friends!
This project is open-sourced software licensed under the MIT license.