ZPLServer for Windows, macOS & Linux
commands to PNG, JPG & PDF!
Key Features
Preview ZPL commands without wasting real labels!
High Quality & Accuracy ZPL Rendering
Forward ZPL rendering to any other servers and services
Rest HTTP POST & Raw TCP Socket
Zebra and ZPL are registered trademarks of ZIH Corp.
ZPLServer
is not made by or endorsed by Zebra.
Convert, Preview & Render ZPL commands
ZPLServer for Windows, macOS & Linux installs as a local service/daemon and allows you to Convert, Preview and Render raw ZPL (Zebra Programming Language) commands to well known image and document formats like PNG, JPG, PCX & PDF. It also can be configured to forward the ZPL output rendering to any other server/services (webhook)!
Applications send ZPL to ZPLServer on port 47321 with an HTTP POST or through a raw TCP socket, just like a network label printer, so even legacy apps that print to a Zebra printer can be captured as Windows, Linux or macOS printers.
Features at a Glance
ZPLServer Service/Daemon
ZPLServer installs as a local service/daemon. You can send raw ZPL commands from any software, application or service for file conversion or output forwarding.HTTP POST
Through a JSON payload, you can specify the ZPL commands, the DPI/Resolution, the Default Label Size, the Default Encoding (Code Page), and more... to the ZPLServer REST endpoint. Ideal for application integration.Raw TCP Socket
Just open a socket and write ZPL or JSON directly and get the output rendering ready for printing redirection.High Accuracy ZPL Render
ZPLServer renders ZPL commands generating high quality output by reproducing built-in and resident ZPL fonts for texts and barcodes with high accuracy. Custom Zebra Intellifont is also supported!Convert ZPL to Images & Docs
Use ZPLServer to easily convert ZPL commands to PNG, JPG, PCX & PDF. Just specify the Write To File action in the Settings web UI tab (zplserver --settings) or through a JSON payload.
Forward ZPL Rendering
Use ZPLServer to easily forward the ZPL output rendering to any other server/service. Just specify the Forward action in the Settings web UI tab (zplserver --settings) or through a JSON payload.
Barcode Symbologies Support
ZPLServer can generate most of the linear (1D), postal, composite, stacked and 2D barcodes shipped with real Zebra printer devices.Colored Label Simulation
ZPLServer can be configured to convert and print ZPL to PNG, JPG & PDF formats simulating a color ribbon (for label items) and a background color label. Black & White 1bpp is also supported through PCX format.On-Premise Licensing
ZPLServer is licensed for Private On-Premise environments. License is available for individual Windows, macOS & Linux devices or for Corporate-wide.Download, Install & System Requirements
ZPLServer is a self-contained binary (no runtime to install). Each download (Windows x64, Linux x64, Linux ARM64, macOS Apple Silicon, macOS Intel) is a ZIP with the binary and an install script that registers ZPLServer as a service that starts automatically at boot, with no user logged in.
| Platform | Requirements | Install | Runs as |
|---|---|---|---|
| Windows x64 | Windows 10 / 11 or Windows Server 2016 or later (64-bit). Administrator rights. | .\install.ps1 from PowerShell as Administrator. Installs to C:\Program Files\ZPLServer\ | Windows Service |
| Linux x64 & ARM64 | glibc 2.17 or later: Ubuntu 20.04+, Debian 11+, RHEL / CentOS / AlmaLinux 8+ or equivalent. systemd and sudo. | sudo ./install.sh. Installs to /opt/zplserver/ | systemd service, dedicated zplserver system account |
| macOS (Apple Silicon & Intel) | macOS 12 Monterey or later, on Apple Silicon (M1 or later) or Intel Macs. sudo. | sudo ./install.sh. Installs to /usr/local/zplserver/ | launchd system daemon |
Verify the installation
# Windows (PowerShell)
& "C:\Program Files\ZPLServer\ZPLServer.exe" --health
& "C:\Program Files\ZPLServer\ZPLServer.exe" --settings
# Linux
sudo systemctl status zplserver
/opt/zplserver/ZPLServer --settings
# macOS
sudo launchctl list | grep zplserver
/usr/local/zplserver/ZPLServer --settings
In the examples on this page, zplserver stands for the full path of the binary shown above. On PowerShell, use the & call operator when the path is quoted.
Open the port to other machines
Only needed if other computers will send ZPL to ZPLServer. The default port is 47321; check it with zplserver --port and change it with zplserver --set-port <port> (applied without restarting):
# Windows
New-NetFirewallRule -DisplayName "ZPLServer" -Direction Inbound -Protocol TCP -LocalPort 47321 -Action Allow
# Linux (ufw)
sudo ufw allow 47321/tcp comment "ZPLServer"
# Linux (firewalld)
sudo firewall-cmd --permanent --add-port=47321/tcp && sudo firewall-cmd --reload
On macOS, allow incoming connections when prompted or in System Settings → Network → Firewall → Options.
Settings, logs and license files
Everything is configured from the Settings web UI (zplserver --settings), and the license can also be set with zplserver --set-license <key>. Files are stored per user account running the service (on Linux, the zplserver account):
| Platform | Settings, license and logs folder |
|---|---|
| Windows | %LOCALAPPDATA%\ZPLServer\ (settings, license, logs) |
| Linux | ~/.local/share/ZPLServer/ (settings, license, logs) |
| macOS | ~/Library/Application Support/ZPLServer/ (settings, license, logs) |
Uninstall
Run .\uninstall.ps1 (Windows, as Administrator) or sudo ./uninstall.sh (Linux, macOS). Add -RemoveData (Windows) or --remove-data (Linux, macOS) to also delete settings and license data.
Troubleshooting
| Issue | Action |
|---|---|
install.ps1 blocked by execution policy (Windows) | Run Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass first |
| Service fails to start (Windows) | Event Viewer → Windows Logs → Application; check sc.exe query ZPLServer |
| Service fails to start (Linux) | journalctl -u zplserver -n 50 |
glibc version too old (Linux) | Upgrade to a supported distribution |
libSkiaSharp.dylib not found (macOS) | Keep it in the same folder as the binary (/usr/local/zplserver/) |
Service not listed by launchctl (macOS) | Check /usr/local/zplserver/stderr.log |
Quick Developer Guide
ZPLServer listens on a single TCP port 47321 and accepts ZPL commands in two ways:
- HTTP POST — Send a JSON payload to a REST endpoint. Best for application integration.
- Raw TCP socket — Open a socket and write ZPL or JSON directly. Best for printer emulation and legacy tools.
You can check the port currently in use under the Settings web UI tab (zplserver --settings), or run zplserver --port from the command line.
1 — Sending ZPL via HTTP (REST API)
ZPLServer exposes two HTTP endpoints on the same port used by the web interface.
| Endpoint | Method | Body | Response |
|---|---|---|---|
/render |
POST | JSON payload (see below) | Rendered image/PDF binary (or ZIP for multi-label jobs) |
/render |
POST | JSON payload with "action": "writetofile" |
Saves the output to disk; same binary response |
/render |
POST | JSON payload with "action": "forward" |
Forwards output to the URL in forwardTo; same binary response |
/render endpoint always returns the rendered bytes directly to the caller.
The action field controls whether the output is also saved to disk or forwarded — it does not suppress the HTTP response.
JSON Payload Reference
Send Content-Type: application/json with a body like the example below. All fields are optional and fall back to the values configured in the Settings web UI tab (zplserver --settings).
| Field | Type | Default | Description |
|---|---|---|---|
zplCommands | string | — | ZPL II command string. Required. |
zplCommandsCodePage | number | 850 | Code page used to encode the ZPL string (e.g. 850, 1252, 65001 for UTF-8). |
isZplCommandsBase64 | bool | false | Set to true if zplCommands is Base64-encoded. |
dpi | number | 203 | Label printer DPI (203 or 300 are typical values). |
labelWidthInchUnit | number | 4 | Label width in inches. |
labelHeightInchUnit | number | 6 | Label height in inches. |
forceLabelWidth | bool | false | Force the rendered output to exactly the specified width. |
forceLabelHeight | bool | false | Force the rendered output to exactly the specified height. |
antiAlias | bool | false | Enable anti-aliasing for smoother output. |
labelBackColorHex | string | #ffffff | Label background color as a hex string (e.g. #ffffff). |
ribbonColorHex | string | #000000 | Ribbon/ink color as a hex string. |
compressionQuality | number | 100 | JPEG/PNG compression quality (1–100). |
action | string | writetofile | writetofile saves output to disk; forward POSTs output to forwardTo. |
fileFolder | string | {Temp}/label_{Ticks} | Output folder path. Supports {ServiceData}, {Temp}, {Ticks} placeholders. |
fileFormat | string | PNG | Output format: PNG, JPG, PDF, PCX, PCL, GRF, EPL, FP, NV. |
forwardTo | string | " | Webhook URL to POST the rendered output to when action is forward. |
HTTP Examples
-
Windows PowerShell — render to PNG and save to disk
$body = @{ zplCommands = "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" dpi = 203 labelWidthInchUnit = 4 labelHeightInchUnit= 6 action = "writetofile" fileFormat = "PNG" fileFolder = "{Temp}/labels" } | ConvertTo-Json Invoke-RestMethod -Method Post ` -Uri "http://localhost:47321/render" ` -ContentType "application/json" ` -Body $body ` -OutFile "label.png" -
Windows PowerShell — receive raw bytes from /render
$body = @{ zplCommands = "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" dpi = 203 labelWidthInchUnit = 4 labelHeightInchUnit= 6 fileFormat = "PNG" } | ConvertTo-Json Invoke-RestMethod -Method Post ` -Uri "http://localhost:47321/render" ` -ContentType "application/json" ` -Body $body ` -OutFile "label.png" -
macOS / Linux curl — render to PNG (binary output)
curl -s -X POST http://localhost:47321/render \ -H "Content-Type: application/json" \ -d '{ "zplCommands": "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ", "dpi": 203, "labelWidthInchUnit": 4, "labelHeightInchUnit": 6, "fileFormat": "PNG" }' \ -o label.png -
macOS / Linux curl — render to PDF and save to a folder
curl -s -X POST http://localhost:47321/render \ -H "Content-Type: application/json" \ -d '{ "zplCommands": "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ", "dpi": 203, "fileFormat": "PDF", "action": "writetofile", "fileFolder": "{Temp}/labels" }' \ -o label.pdf -
macOS / Linux curl — forward rendered output to a webhook
curl -s -X POST http://localhost:47321/render \ -H "Content-Type: application/json" \ -d '{ "zplCommands": "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ", "fileFormat": "PNG", "action": "forward", "forwardTo": "https://my.server.com/label-webhook" }'
2 — Sending ZPL via Raw TCP Socket
ZPLServer listens on the same port for raw TCP connections. You can write either:
- Plain ZPL commands (e.g.
^XA...^XZ) — the server uses the settings from the Settings web UI tab (zplserver --settings). - A complete JSON payload — the server parses it and applies any overrides before rendering.
This mode is compatible with any tool or language that can open a TCP socket: Zebra printers, legacy applications, scripts, etc.
Raw Socket Examples
-
Windows PowerShell — send raw ZPL over TCP
$zpl = "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" $port = 47321 $enc = [System.Text.Encoding]::GetEncoding(850) $client = New-Object System.Net.Sockets.TcpClient("127.0.0.1", $port) $stream = $client.GetStream() $bytes = $enc.GetBytes($zpl) $stream.Write($bytes, 0, $bytes.Length) $stream.Flush() $stream.Close() $client.Close() -
Windows PowerShell — send JSON payload over TCP
$json = @{ zplCommands = "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" dpi = 203 labelWidthInchUnit = 4 labelHeightInchUnit= 6 fileFormat = "PDF" action = "writetofile" fileFolder = "{Temp}/labels" } | ConvertTo-Json -Compress $port = 47321 $enc = [System.Text.Encoding]::UTF8 $client = New-Object System.Net.Sockets.TcpClient("127.0.0.1", $port) $stream = $client.GetStream() $bytes = $enc.GetBytes($json) $stream.Write($bytes, 0, $bytes.Length) $stream.Flush() $stream.Close() $client.Close() -
macOS / Linux nc (netcat) — send raw ZPL
echo -n "^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" | nc 127.0.0.1 47321 -
macOS / Linux nc (netcat) — send a JSON payload from a file
# Create payload.json first, then: nc 127.0.0.1 47321 < payload.json -
Linux bash /dev/tcp — no extra tools needed
ZPL="^XA^FO30,40^ADN,36,20^FDHello World^FS^XZ" exec 3>/dev/tcp/127.0.0.1/47321 printf "$ZPL" >&3 exec 3>&-
3a — Windows Virtual Printer Setup
On Windows you can configure ZPLServer as a Standard TCP/IP printer port. Any application that prints to this virtual printer will have its ZPL stream captured and processed by ZPLServer automatically.
-
Open Devices and Printers:
- Windows 11 / 10 Right-click Start → Settings → Bluetooth & devices → Printers & scanners
- Windows 8 / 7 Start → Control Panel → Hardware and Sound → Devices and Printers
- Click Add a printer → The printer that I want isn't listed.
- Select Add a local printer or network printer with manual settings → Next.
- Select Create a new port, choose Standard TCP/IP Port → Next.
-
Enter:
- Host Name or IP Address:
127.0.0.1 - Port Name: any name you like, e.g.
ZPLServer_local - Uncheck Query the printer and automatically select the driver to use
- Host Name or IP Address:
- When prompted for a driver, choose any Generic / Text Only driver.
-
After the port is created, open its Properties → Ports tab → select the port → Configure Port and set the Port Number to match the value returned by
zplserver --port. - Click Finish. The new printer will now forward all print jobs to ZPLServer.
3b — Linux: CUPS Virtual Printer Setup
On Linux you can add ZPLServer as a raw CUPS printer. Any application that prints to it will have its ZPL stream sent directly to ZPLServer over a socket connection.
Tip: CUPS must be installed and running.
- Debian/Ubuntu:
sudo apt install cups - Fedora/RHEL:
sudo dnf install cups - Start:
sudo systemctl start cups
Option A — Command line (recommended)
Run the following as a user with lpadmin privileges (or prefix with sudo):
# Add the printer — replace 47321 with the port shown by zplserver --port
lpadmin -p ZPLServer \
-E \
-v socket://127.0.0.1:47321 \
-m raw \
-D "ZPLServer virtual ZPL printer" \
-L "localhost"
# Set it as the system default (optional)
lpoptions -d ZPLServer
The -m raw flag tells CUPS to forward the print data unmodified — no driver translation occurs,
so ZPL commands reach ZPLServer exactly as sent by the application.
Option B — CUPS web interface
- Open http://localhost:631 in a browser.
- Go to Administration Add Printer.
- Select AppSocket/HP JetDirect and click Continue.
-
Set the connection URI to:
socket://127.0.0.1:47321
- Give it a name (e.g.
ZPLServer), click Continue. - Under Make choose Raw, under Model choose Raw Queue (en).
- Click . Done.
3c — macOS: Printers & Scanners Setup
macOS uses CUPS under the hood, so the same raw socket approach works. You can add ZPLServer either through the Printers & Scanners System Settings panel or from the Terminal.
Option A — Terminal (fastest)
# Replace 47321 with the port shown by zplserver --port
lpadmin -p ZPLServer \
-E \
-v socket://127.0.0.1:47321 \
-m raw \
-D "ZPLServer virtual ZPL printer"
# Set as default printer (optional)
lpoptions -d ZPLServer
Note: On macOS Ventura and later, lpadmin may require full disk access for the terminal app, or you can prefix with sudo.
If the command is not found, install the Xcode Command Line Tools: xcode-select --install.
Option B — System Settings GUI
- Open System Settings (macOS Ventura 13+) or System Preferences (macOS Monterey 12 and earlier) Printers & Scanners.
- Click the (Add Printer) button.
- In the Add Printer dialog, click the IP tab ( globe icon).
-
Fill in the fields:
- Address:
127.0.0.1 - Protocol:
HP Jetdirect - Socket - Queue: leave blank
- Name:
ZPLServer(or any name you like) - Use / Driver: select
Generic PostScript PrinterorAirPrint— then immediately change it to Select Software… Generic Generic PostScript Printer. The driver is irrelevant because CUPS will use the raw queue.
- Address:
- Click . The printer appears in the list.
-
Important: right-click (or Control-click) the new printer in the list and choose
Show Printers in Finder to verify the queue name, then match it to the port configured
in ZPLServer which can be obtained through
zplserver --port.
Note: macOS may display a driver warning because it expects a PostScript or AirPrint device. This is harmless — ZPLServer receives the raw bytes before any driver conversion takes place when the queue is set to raw via Terminal.
If you use the GUI-only route, test with a small ZPL print job and check the
Logs page (zplserver --logs) to confirm ZPLServer received the data.
4 — Redirect Print
-
Windows PowerShell — render to image → save to disk → file system watcher → printing
<# .SYNOPSIS Watches the ZPLServer output folder (action: "writetofile", fileFormat: "PNG") and prints each rendered label to a standard Windows-installed HP printer, using System.Drawing.Printing on regular A4 or Letter paper. .DESCRIPTION ZPLServer renders each label and saves it to disk ("writetofile") or forwards it to a webhook ("forward"). This script prints those labels on an office printer: it watches the folder ZPLServer writes to, and as soon as a new label image appears, it prints it on a regular office printer (A4 / Letter), placing the label at its real physical size (in inches) rather than stretching it to fill the whole page. .NOTES - ZPLServer must be configured with fileFormat "PNG" or "JPG". Do NOT use "PDF": System.Drawing.Image cannot load PDF files directly. - Set $WatchFolder to match the "fileFolder" value used in ZPLServer's payload/Settings. - Set $PrinterName to the EXACT name shown in Windows. List available printers with: Get-Printer | Select-Object Name - Set $PageSize to "A4" or "Letter" depending on the paper loaded in the printer. .EXAMPLE powershell -ExecutionPolicy Bypass -File .\Watch-And-Print-ZPL.ps1 #> param( [string]$WatchFolder = "C:\ZPLServer\labels", [string]$PrinterName = "HP LaserJet Pro M404-M405", [ValidateSet("A4", "Letter")] [string]$PageSize = "Letter", [double]$LabelWidthIn = 4, [double]$LabelHeightIn = 6, [double]$OffsetXIn = 0.25, # horizontal position of the label on the page [double]$OffsetYIn = 0.25, # vertical position of the label on the page [switch]$DeleteAfterPrint = $true, [string]$FailedFolder = "C:\ZPLServer\labels\_failed" ) Add-Type -AssemblyName System.Drawing if (-not (Test-Path $WatchFolder)) { New-Item -ItemType Directory -Path $WatchFolder -Force | Out-Null } if (-not (Test-Path $FailedFolder)) { New-Item -ItemType Directory -Path $FailedFolder -Force | Out-Null } # ------------------------------------------------------------------------- # Waits until a file is fully written and no longer locked by another # process (ZPLServer may still be flushing it to disk when the Created # event fires). # ------------------------------------------------------------------------- function global:Wait-FileReady { param([string]$Path, [int]$TimeoutMs = 5000) $elapsed = 0 while ($elapsed -lt $TimeoutMs) { try { $stream = [System.IO.File]::Open($Path, 'Open', 'Read', 'None') $stream.Close() return $true } catch { Start-Sleep -Milliseconds 150 $elapsed += 150 } } return $false } # ------------------------------------------------------------------------- # Prints a label image (PNG/JPG) at its real physical size onto a standard # sheet of paper (A4 or Letter), positioned at (OffsetXIn, OffsetYIn). # ------------------------------------------------------------------------- function global:Print-LabelImage { param( [Parameter(Mandatory)][string]$ImagePath, [Parameter(Mandatory)][string]$PrinterName, [Parameter(Mandatory)][string]$PageSize, [double]$LabelWidthIn, [double]$LabelHeightIn, [double]$OffsetXIn, [double]$OffsetYIn ) $img = [System.Drawing.Image]::FromFile($ImagePath) try { $pd = New-Object System.Drawing.Printing.PrintDocument $pd.PrinterSettings.PrinterName = $PrinterName if (-not $pd.PrinterSettings.IsValid) { $available = (Get-Printer).Name -join ', ' throw "Printer '$PrinterName' was not found or is not available. Detected printers: $available" } # Select the requested standard paper size (A4 or Letter) from # what the driver reports, instead of forcing a custom size. $kindWanted = if ($PageSize -eq "A4") { [System.Drawing.Printing.PaperKind]::A4 } else { [System.Drawing.Printing.PaperKind]::Letter } $matchedPaper = $null foreach ($ps in $pd.PrinterSettings.PaperSizes) { if ($ps.Kind -eq $kindWanted) { $matchedPaper = $ps break } } if ($matchedPaper) { $pd.DefaultPageSettings.PaperSize = $matchedPaper } else { Write-Warning "Printer '$PrinterName' does not report a '$PageSize' paper size; falling back to its default paper size." } $pd.DefaultPageSettings.Margins = New-Object System.Drawing.Printing.Margins(0,0,0,0) $pd.OriginAtMargins = $false $handler = { param($sender, $e) # 100 units = 1 inch in GDI+ page units used by PrintDocument $destRect = New-Object System.Drawing.RectangleF( [float]($OffsetXIn * 100), [float]($OffsetYIn * 100), [float]($LabelWidthIn * 100), [float]($LabelHeightIn * 100) ) $e.Graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic $e.Graphics.DrawImage($img, $destRect) $e.HasMorePages = $false } $pd.add_PrintPage($handler.GetNewClosure()) $pd.Print() } finally { $img.Dispose() } } # ------------------------------------------------------------------------- # FileSystemWatcher: triggers printing whenever a new label file appears # ------------------------------------------------------------------------- $watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = $WatchFolder $watcher.Filter = "*.*" # extension is filtered below (png/jpg) $watcher.IncludeSubdirectories = $false $watcher.EnableRaisingEvents = $true $action = { $cfg = $Event.MessageData # settings passed with -MessageData ($using: does not work in event actions) $path = $Event.SourceEventArgs.FullPath $ext = [System.IO.Path]::GetExtension($path).ToLowerInvariant() if ($ext -notin @(".png", ".jpg", ".jpeg")) { return } if (-not (Wait-FileReady -Path $path)) { Write-Warning "Timed out waiting for '$path' to become ready." return } try { Print-LabelImage -ImagePath $path ` -PrinterName $cfg.PrinterName ` -PageSize $cfg.PageSize ` -LabelWidthIn $cfg.LabelWidthIn ` -LabelHeightIn $cfg.LabelHeightIn ` -OffsetXIn $cfg.OffsetXIn ` -OffsetYIn $cfg.OffsetYIn Write-Host "$(Get-Date -Format 'HH:mm:ss') Printed: $path" if ($cfg.DeleteAfterPrint) { Remove-Item -LiteralPath $path -Force } } catch { Write-Warning "Failed to print '$path': $($_.Exception.Message)" try { Move-Item -LiteralPath $path -Destination $cfg.FailedFolder -Force } catch {} } } $cfg = @{ PrinterName = $PrinterName; PageSize = $PageSize LabelWidthIn = $LabelWidthIn; LabelHeightIn = $LabelHeightIn OffsetXIn = $OffsetXIn; OffsetYIn = $OffsetYIn DeleteAfterPrint = [bool]$DeleteAfterPrint; FailedFolder = $FailedFolder } Register-ObjectEvent -InputObject $watcher -EventName Created -Action $action -MessageData $cfg | Out-Null Write-Host "Watching '$WatchFolder' -> printing to '$PrinterName' on $PageSize paper. Press Ctrl+C to stop." -ForegroundColor Cyan # Keeps the script alive try { while ($true) { Start-Sleep -Seconds 1 } } finally { Get-EventSubscriber | Unregister-Event $watcher.Dispose() } -
Windows PowerShell — render to image → forward to a listener → printing
#------------------------------------------------------------------------ # In ZPLServer, instead of "action": "writetofile", use: # "action": "forward", # "forwardTo": "http://127.0.0.1:9191/print" # # Then run a local listener that receives the POST body and prints it # immediately, without touching disk. Minimal example: #------------------------------------------------------------------------ # Requires the Print-LabelImage function and the $PrinterName, $PageSize, $LabelWidthIn, # $LabelHeightIn, $OffsetXIn and $OffsetYIn values from the previous script. $listener = New-Object System.Net.HttpListener $listener.Prefixes.Add("http://127.0.0.1:9191/print/") $listener.Start() Write-Host "Listening for ZPLServer forwardTo requests on http://127.0.0.1:9191/print/" while ($listener.IsListening) { $context = $listener.GetContext() $req = $context.Request $ms = New-Object System.IO.MemoryStream $req.InputStream.CopyTo($ms) $bytes = $ms.ToArray() $tmp = [System.IO.Path]::GetTempFileName() + ".png" [System.IO.File]::WriteAllBytes($tmp, $bytes) try { Print-LabelImage -ImagePath $tmp -PrinterName $PrinterName -PageSize $PageSize ` -LabelWidthIn $LabelWidthIn -LabelHeightIn $LabelHeightIn ` -OffsetXIn $OffsetXIn -OffsetYIn $OffsetYIn } finally { Remove-Item $tmp -Force -ErrorAction SilentlyContinue } $context.Response.StatusCode = 200 $context.Response.Close() } -
macOS / Linux — render to image → save to disk → file system watcher → printing
#!/usr/bin/env bash # # Watch-And-Print-ZPL.sh # # Watches the ZPLServer output folder (action: "writetofile", fileFormat: "PDF") # and prints each rendered label to a standard HP printer installed on # macOS/Linux, using CUPS (lp) on regular A4 or Letter paper. # # ZPLServer renders each label and saves it to disk ("writetofile") or forwards it # to a webhook ("forward"). This script prints those labels on an office printer by watching the folder ZPLServer writes to and # printing each new label as soon as it appears. # # REQUIREMENTS # - ZPLServer configured with fileFormat "PDF". # - CUPS client tools (`lp`, `lpstat`) available: # macOS -> included by default. # Linux -> install with: sudo apt-get install cups-client # - The target printer must already be added/shared in CUPS # (System Settings > Printers & Scanners on macOS, or `lpadmin`/ # CUPS web UI on Linux). List installed printers with: lpstat -p # - (Optional, recommended) fswatch for real-time folder monitoring: # macOS -> brew install fswatch # Linux -> sudo apt-get install fswatch # If fswatch is not installed, the script falls back to polling. # # USAGE # chmod +x Watch-And-Print-ZPL.sh # PRINTER_NAME="HP_LaserJet_Pro_M404" WATCH_FOLDER="/usr/local/zplserver/labels" \ # ./Watch-And-Print-ZPL.sh # # All settings can also be edited directly below instead of passed as # environment variables. set -euo pipefail # --------------------------------------------------------------------------- # Configuration # --------------------------------------------------------------------------- WATCH_FOLDER="${WATCH_FOLDER:-/usr/local/zplserver/labels}" FAILED_FOLDER="${FAILED_FOLDER:-$WATCH_FOLDER/_failed}" PRINTER_NAME="${PRINTER_NAME:-HP_LaserJet_Pro_M404}" # exact CUPS queue name, see: lpstat -p PAGE_SIZE="${PAGE_SIZE:-Letter}" # Letter or A4 FIT_MODE="${FIT_MODE:-fit-to-page}" # fit-to-page | natural DELETE_AFTER_PRINT="${DELETE_AFTER_PRINT:-true}" POLL_INTERVAL="${POLL_INTERVAL:-1}" # seconds, only used by the polling fallback mkdir -p "$WATCH_FOLDER" "$FAILED_FOLDER" log() { printf '%s %s\n' "$(date '+%H:%M:%S')" "$*" } # --------------------------------------------------------------------------- # Waits until a file's size is stable across two checks, meaning ZPLServer # has finished writing it to disk (avoids printing a half-written PDF). # --------------------------------------------------------------------------- wait_file_ready() { local file="$1" local timeout_ticks=20 # ~ timeout_ticks * 0.3s = 6s max wait local tick=0 local prev_size=-1 while [ "$tick" -lt "$timeout_ticks" ]; do [ -f "$file" ] || return 1 local size size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null || echo -1) if [ "$size" != "-1" ] && [ "$size" != "0" ] && [ "$size" = "$prev_size" ]; then return 0 fi prev_size="$size" sleep 0.3 tick=$((tick + 1)) done return 1 } # --------------------------------------------------------------------------- # Prints a single PDF label file to the configured HP printer via CUPS. # --------------------------------------------------------------------------- print_label() { local file="$1" if ! command -v lp >/dev/null 2>&1; then log "ERROR: 'lp' command not found. Install CUPS client tools (cups-client on Linux; CUPS ships with macOS)." return 1 fi local fit_opts if [ "$FIT_MODE" = "fit-to-page" ]; then # Scales the label PDF to fit within the printable area of the page. fit_opts="-o fit-to-page" else # Prints the label at its real physical size, anchored top-left, # instead of scaling it to fill the page. fit_opts="-o natural-scaling=100 -o position=top-left" fi local lp_log lp_log="$(mktemp)" # shellcheck disable=SC2086 if lp -d "$PRINTER_NAME" -o media="$PAGE_SIZE" $fit_opts "$file" >"$lp_log" 2>&1; then log "Printed: $file" rm -f "$lp_log" return 0 else log "ERROR printing '$file': $(cat "$lp_log")" rm -f "$lp_log" return 1 fi } # --------------------------------------------------------------------------- # Handles a newly detected file: waits for it to be ready, prints it, then # either deletes it or moves it to the failed folder. # --------------------------------------------------------------------------- handle_file() { local file="$1" local ext="${file##*.}" case "$ext" in pdf|PDF) ;; *) return 0 ;; # ignore anything that isn't a PDF esac if ! wait_file_ready "$file"; then log "WARNING: timed out waiting for '$file' to become ready." return fi if print_label "$file"; then if [ "$DELETE_AFTER_PRINT" = "true" ]; then rm -f "$file" fi else mv -f "$file" "$FAILED_FOLDER/" 2>/dev/null || true fi } log "Watching '$WATCH_FOLDER' -> printing to '$PRINTER_NAME' on $PAGE_SIZE paper (mode: $FIT_MODE)." # --------------------------------------------------------------------------- # Preferred: fswatch for real-time, event-driven monitoring. # Fallback: simple polling loop, works everywhere with no extra dependencies. # --------------------------------------------------------------------------- if command -v fswatch >/dev/null 2>&1; then log "Using fswatch for real-time folder monitoring." fswatch -0 "$WATCH_FOLDER" | while IFS= read -r -d "" changed_file; do [ -f "$changed_file" ] && handle_file "$changed_file" done else log "fswatch not found; falling back to polling every ${POLL_INTERVAL}s." log "Tip: install fswatch for lower latency (brew install fswatch / apt-get install fswatch)." declare -A seen while true; do shopt -s nullglob for f in "$WATCH_FOLDER"/*.pdf "$WATCH_FOLDER"/*.PDF; do if [ -z "${seen[$f]:-}" ]; then seen[$f]=1 handle_file "$f" fi done shopt -u nullglob sleep "$POLL_INTERVAL" done fi -
macOS / Linux — render to image → forward to a listener → printing
# In ZPLServer, instead of "action": "writetofile", use: # "action": "forward", # "forwardTo": "http://127.0.0.1:9191/print" # # Then run a small local HTTP listener that receives the POST body and # prints it immediately, without touching disk. Minimal Python 3 example # (Python 3 ships by default on macOS and most Linux distributions): # Run it with: python3 forward_listener.py #!/usr/bin/env python3 import subprocess, tempfile from http.server import BaseHTTPRequestHandler, HTTPServer PRINTER_NAME = "HP_LaserJet_Pro_M404" PAGE_SIZE = "Letter" class Handler(BaseHTTPRequestHandler): def do_POST(self): length = int(self.headers.get("Content-Length", 0)) body = self.rfile.read(length) with tempfile.NamedTemporaryFile(suffix=".pdf", delete=False) as f: f.write(body) tmp_path = f.name result = subprocess.run( ["lp", "-d", PRINTER_NAME, "-o", f"media={PAGE_SIZE}", "-o", "fit-to-page", tmp_path], capture_output=True, text=True, ) if result.returncode == 0: print(f"Printed: {tmp_path}") self.send_response(200) else: print(f"ERROR printing: {result.stderr}") self.send_response(500) self.end_headers() HTTPServer(("127.0.0.1", 9191), Handler).serve_forever()
5 — Command-Line Interface (CLI)
Run zplserver from a terminal with the following flags:
| Command | Description |
|---|---|
zplserver | Start the background service (normal mode). |
zplserver --settings | Open the Settings page in the default browser. |
zplserver --logs | Open the Logs page in the default browser. |
zplserver --port | Print the port ZPLServer is currently listening on. |
zplserver --device-id | Print the unique Device ID for this installation (used for licensing). |
zplserver --health | Check whether the service is running. Exits with code 0 (OK) or 1 (FAIL). |
zplserver --set-port <port> | Change the listening port (hot-reload if running) |
zplserver --set-license <key> | Set the license key (hot-reload if running) |
zplserver --doc | Show the doc page in the default browser. |
zplserver --help | Show this summary in the console. |
zplserver stands for the full path of the binary: C:\Program Files\ZPLServer\ZPLServer.exe, /opt/zplserver/ZPLServer or /usr/local/zplserver/ZPLServer.
ZPLServer FAQ
- How do I convert ZPL to PDF with a local service?
- Install ZPLServer and POST a JSON payload with the zplCommands and "fileFormat": "PDF" to http://localhost:47321/render. The response is the rendered PDF. You can also save it to a folder with "action": "writetofile".
- Can legacy applications that print to a Zebra printer send ZPL to ZPLServer?
- Yes. ZPLServer accepts raw ZPL over a TCP socket on port 47321, like a network label printer. On Windows add a Standard TCP/IP printer port pointing to 127.0.0.1:47321; on Linux and macOS add a raw CUPS queue with socket://127.0.0.1:47321. The application keeps printing as usual and ZPLServer captures and renders each label.
- Can ZPLServer send the rendered labels to another system?
- Yes. With "action": "forward" and a "forwardTo" URL, ZPLServer POSTs the rendered output (PDF, PNG and other formats) to your webhook, for example to archive labels or attach them to orders.
- Can ZPLServer print the labels on an office printer?
- ZPLServer renders the labels and saves them to disk or forwards them to a webhook. To print them on a laser or inkjet printer, use the ready-made scripts on this page that watch the output folder or receive the webhook and print each label, or use the Virtual ZPL Printer Driver, which has a built-in Print To action.
- Which output formats are supported?
- PNG, JPG, PDF, PCX and HP PCL, plus printer formats: Zebra GRF (ZPL), Zebra EPL, Honeywell FingerPrint and EPSON ESC/POS NV.
- Can it run at startup without a logged-in user?
- Yes. The install scripts included in the download register ZPLServer as a Windows Service, a systemd service on Linux or a launchd daemon on macOS, so it starts at boot. Check it with zplserver --health.
- Which operating systems and architectures are supported?
- Windows 10 / 11 and Windows Server 2016 or later (x64), Linux x64 and ARM64 with glibc 2.17 or later (Ubuntu 20.04+, Debian 11+, RHEL / CentOS / AlmaLinux 8+), and macOS 12 Monterey or later on Apple Silicon and Intel Macs. The binary is self-contained, so no runtime needs to be installed. See system requirements.
- How do I install ZPLServer?
- Download the ZIP for your platform and run the included script: .\install.ps1 from an Administrator PowerShell on Windows, or sudo ./install.sh on Linux and macOS. It copies the binary, registers the service and starts it.
- Which port does it use?
- ZPLServer listens on TCP port 47321 by default for both HTTP and raw TCP. Run zplserver --port to see it and zplserver --set-port to change it.
Which ZPL Edition Do I Need?
The same ZPL rendering engine is available in four editions:
| Edition | Best for | How you use it | Platforms |
|---|---|---|---|
| ZPLPrinter Emulator SDK for .NET | .NET apps (C#, VB.NET) | In-process library: convert, preview and print from code | Windows, Linux, macOS (.NET Standard 2.0) |
| ZPLPrinter Web API for Docker | Any language, servers and cloud | REST API in a Docker container | Linux container (amd64 & arm64) |
| Virtual ZPL Printer Driver | Desktop users and apps that print to a Zebra printer | Installed printer: save ZPL as PDF/PNG or print it on any other printer | Windows, macOS |
| ZPLServer | Background integration and legacy apps | Local service: HTTP POST + raw TCP; save to disk or forward to a webhook | Windows x64, Linux x64 & ARM64, macOS (Apple Silicon & Intel) |
ZPL Commands Support
ZPLServer rendering engine supports most of the ZPL formatting and control commands. The following table lists the supported commands. Not listed or unsupported commands will be skipped in the parsing stage.
Barcode symbols, particularly 2D-type like QR Code, Data Matrix, Aztec Code, Maxicode..., might look different to the one printed by a real printer because ZPLServer leverages on its own barcode encoder. However, this does not mean that the rendered barcodes will not be readable at all.
| Status | ZPL Command | Notes |
|---|---|---|
| ^A Scalable/Bitmapped Font | ||
| ^A@ Use Font Name to Call Font | .FNT extension is not supported | |
| ^B0 Aztec Bar Code Parameters | ECICs and Structured Appended format are not supported | |
| ^B1 Code 11 Bar Code | ||
| ^B2 Interleaved 2 of 5 Bar Code | ||
| ^B3 Code 39 Bar Code | ||
| ^B4 Code 49 | Starting mode is not supported | |
| ^B5 Planet Code bar code | ||
| ^B7 PDF417 Bar Code | ||
| ^B8 EAN-8 Bar Code | ||
| ^B9 UPC-E Bar Code | ||
| ^BA Code 93 Bar Code | ||
| ^BB Codablock | Codablock-F supported only | |
| ^BC Code 128 Bar Code (Subsets A, B, and C) | ||
| ^BD UPS MaxiCode Bar Code | ||
| ^BE EAN-13 Bar Code | ||
| ^BF MicroPDF417 Bar Code | ||
| ^BI Industrial 2 of 5 Bar Codes | ||
| ^BJ Standard 2 of 5 Bar Code | ||
| ^BK ANSI Codabar Bar Code | ||
| ^BL LOGMARS Bar Code | ||
| ^BM MSI Bar Code | ||
| ^BO Aztec Bar Code Parameters | ECICs and Structured Appended format are not supported | |
| ^BP Plessey Bar Code | ||
| ^BQ QR Code Bar Code | Model 1 and Data Encoding Switches are not supported | |
| ^BR GS1 Databar | ||
| ^BS UPC/EAN Extensions | ||
| ^BT TLC39 | ||
| ^BU UPC-A Bar Code | ||
| ^BX Data Matrix Bar Code | Quality Level < 200 is not supported | |
| ^BY Bar Code Field Default | ||
| ^BZ POSTAL Bar Code | ||
| ^CC Change Caret | ||
| ^CD Change Delimiter | ||
| ^CF Change Alphanumeric Default Font | ||
| ^CI Change International Font/Encoding | Character remapping is not supported | |
| ^CT Change Tilde | ||
| ^CW Font Identifier | ||
| ~DB Download Bitmap Font | ||
| ^DF Download Format | ||
| ~DG Download Graphics | ||
| ~DU Download Unbounded TrueType Font | ||
| ~DY Download Objects | AR-compressed format and bitmap, .pcx, .nrd, .pac, .wml, .htm, .get extensions are not supported | |
| ~EG Erase Download Graphics | ||
| ^FA Field Allocate | ||
| ^FB Field Block | ||
| ^FC Field Clock | ||
| ^FD Field Data | ||
| ^FH Field Hexadecimal Indicator | ||
| ^FL Font Linking | ||
| ^FM Multiple Field Origin Locations | ||
| ^FN Field Number | ||
| ^FO Field Origin | ||
| ^FP Field Parameter | ||
| ^FR Field Reverse Print | ||
| ^FS Field Separator | ||
| ^FT Field Typeset | ||
| ^FV Field Variable | ||
| ^FW Field Orientation | ||
| ^FX Comment | ||
| ^GB Graphic Box | ||
| ^GC Graphic Circle | ||
| ^GD Graphic Diagonal Line | ||
| ^GE Graphic Ellipse | ||
| ^GF Graphic Field | ||
| ^GS Graphic Symbol | ||
| ^ID Object Delete | ||
| ^IL Image Load | ||
| ^IM Image Move | ||
| ^IS Image Save | ||
| ~JR Power On Reset | ||
| ^LH Label Home | ||
| ^LL Label Length | ||
| ^LR Label Reverse Print | ||
| ^LS Label Shift | ||
| ^LT Label Top | ||
| ^MC Map Clear | ||
| ^MU Set Units of Measurement | ||
| ^PA Advanced Text Properties | ||
| ^PM Printing Mirror Image of Label | ||
| ^PO Print Orientation | ||
| ^PQ Print Quantity | ||
| ^PW Print Width | ||
| ^RF Read or Write RFID Format | Only Write mode is supported | |
| ^RQ Quick Write EPC Data and Passwords | ||
| ^SF Serialization Field | ||
| ^SL Set Mode and Language (for Real-Time Clock) | ||
| ^SN Serialization Data | ||
| ^SO Set Offset (for Real-Time Clock) | ||
| ^ST Set Date and Time (for Real-Time Clock) | ||
| ^TB Text Blocks | ||
| ^TO Transfer Object | ||
| ~WC Print Configuration Label | ||
| ^XA Start Format | ||
| ^XF Recall Format | ||
| ^XG Recall Graphic | ||
| ^XZ End Format | ||
| ^WF Encode AFI or DSFID Byte | ||
| ^WT Write (Encode) Tag |