# ZPLServer — macOS x64 (Intel)

ZPLServer is a self-contained background service that processes ZPL label data.
- It can convert ZPL commands to PNG, JPG, PDF, PCX, PCL, GRF, EPL, FP, and NV formats.
- The rendering output can be saved as a file or HTTP POST the rendered output.

## Prerequisites

- macOS 12 Monterey or later on an **Intel Mac**
- Administrator (sudo) access to install the launchd service

## Package Contents

| File | Description |
|---|---|
| `ZPLServer` | Self-contained service binary |
| `libSkiaSharp.dylib` | Native rendering library (must stay in the same folder as `ZPLServer`) |
| `install.sh` | Installs and starts ZPLServer as a launchd system daemon |
| `uninstall.sh` | Stops, removes the daemon, and deletes all files |
| `README.md` | This file |

## Installation

```bash
chmod +x install.sh
sudo ./install.sh
```

The script will:
1. Copy `ZPLServer` and `libSkiaSharp.dylib` to `/usr/local/zplserver/`
2. Write a launchd plist to `/Library/LaunchDaemons/`
3. Load and start the service (runs at boot automatically)

## Verify

```bash
# Check the service is loaded
sudo launchctl list | grep zplserver

# Open Settings in the browser
/usr/local/zplserver/ZPLServer --settings
```

## CLI Reference

| Command | Action |
|---|---|
| *(no args)* | Start the background service |
| `--settings` | Open the Settings page in the browser |
| `--logs` | Open the Logs page in the browser |
| `--doc` | Open the developer guide in browser |
| `--device-id` | Returns the current Device ID |
| `--port` | Returns the current listening port |
| `--set-port <port>` | Change the listening port (hot-reload if running) |
| `--set-license <key>` | Set the license key (hot-reload if running) |
| `--health` | Check if server is running |
| `--help` | Print usage information |

## Logs

Logs are available through the web UI (opened via `--logs`).
The log files are saved at:

```
~/Library/Application Support/ZPLServer/logs
```

## Configuration

All configuration is managed through the web UI (opened via `--settings`).
The settings file is saved at:

```
~/Library/Application Support/ZPLServer/settings
```

## License

Enter your license key through the Settings page.
The license file is stored at:

```
~/Library/Application Support/ZPLServer/license
```

Or run the following:

```bash
/usr/local/zplserver/ZPLServer --set-license <key>
```

## Firewall

macOS does not block outbound connections. If ZPLServer needs to accept connections
from other machines, macOS will prompt to allow it the first time a client connects,
or you can pre-approve via **System Settings → Network → Firewall → Options**.

## Uninstall

```bash
sudo ./uninstall.sh
```

To also remove user settings and license data:

```bash
sudo ./uninstall.sh --remove-data
```

## Troubleshooting

| Issue | Action |
|---|---|
| `install.sh: Permission denied` | Run with `sudo` |
| `libSkiaSharp.dylib` not found at runtime | Ensure it is in the **same directory** as `ZPLServer` (`/usr/local/zplserver/`) |
| Service does not appear in `launchctl list` | Check `/usr/local/zplserver/stderr.log` for startup errors |
| Settings page does not open | Confirm the service is loaded: `sudo launchctl list \| grep zplserver` |
