PrintZPL
Send ZPL templates to a Zebra label printer over TCP/IP. Supports data binding and batch printing.
Install / Use
/learn @Tim-Maes/PrintZPLREADME
PrintZPL
Description
This service allows you to discover Zebra printers and send/print ZPL templates by using HTTP POST requests.
Installation
Download and run as service
- PrintZPL-win-x64 for Windows
- PrintZPL-linux-x64 for Linux
- PrintZPL-osx-x65 for MaxOS
Running as a Service
- Create the service:
sc create MyServiceName ^
binPath= "C:\Full\Path\To\PrintZpl.exe" ^
DisplayName= "PrintZpl" ^
start= auto
- Start the service
sc start PrintZpl
The API
Discovering printers
You can send a GET request to http//localhost:9001/printers
Example response:
[
{
"name": "TestPrinter",
"ipAddress": "192.168.1.30",
"port": 9100,
"model": "ZebraTest"
}
]
Print ZPL Labels
You try sending a request to http://localhost:9001/print/from-zpl
Using these parameters you can send a ZPL template to a printer:
{
"ZPL": "^XA^FO50,50^ADN,36,20^FDHello, world!!^FS^XZ",
"IpAddress": "0.0.0.0.0",
"Port": "6101"
}
Print ZPL Label with data
You can also send data parameters to process a template that has placeholders for data and specify a delimiter.
For example, if you use the $ delimiter in your ZPL template, you can send the following request:
{
"ZPL": "^XA^FO50,50^ADN,36,20^FD$Greeting$, $Name$!^FS^XZ",
"IpAddress": "0.0.0.0.0",
"Port": "6101",
"Data": {
"Greeting": "Hello",
"Name": "World"
},
"Delimiter": "$"
}
$Greeting$ and $Name$ will be replaced by Hello and World respectively.
Print ZPL Labels in batch
Url: http://localhost:9001/batch-print/from-zpl
You can send a batch of ZPL templates to a printer by using the following request:
{
"PrintRequests":
[
{
"ZPL": "^XA^FO50,50^ADN,36,20^FDHello, $Name$!^FS^XZ",
"IpAddress": "0.0.0.0.0",
"Port": "6101",
"Data": {
"Name": "World",
"Name2": "OtherValue"
},
"Delimiter": "$"
},
{
"ZPL": "^XA^FO50,50^ADN,36,20^FDHello, $Name$!^FS^XZ",
"IpAddress": "0.0.0.0.0",
"Port": "6101",
"Data": {
"Name": "World",
"Name2": "OtherValue"
},
"Delimiter": "$"
}
]
}
The code
Building the project
Prerequisites
- .NET 8 SDK
- dotnet build
Running the project
dotnet run
This will start a web server on port 9001.
Pack this repo code as executable
Run this command in the project folder
Windows
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true --self-contained true
Linux
dotnet publish -r linux-x64 -c Release /p:PublishSingleFile=true --self-contained true
MacOs
dotnet publish -r osx-x64 -c Release /p:PublishSingleFile=true --self-contained true
You'll find the output .exe in bin\Release\net8.0\win-x64\publish (or the corresponding folder for your target platform).
