Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Send ZPL templates to a Zebra label printer over TCP/IP. Supports data binding and batch printing.

License

Tim-Maes/PrintZPL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Running as a Service

  1. Create the service:
sc create MyServiceName ^
    binPath= "C:\Full\Path\To\PrintZpl.exe" ^
    DisplayName= "PrintZpl" ^
    start= auto
  1. 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).

About

Send ZPL templates to a Zebra label printer over TCP/IP. Supports data binding and batch printing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages