A simple web server built with Hono.js that handles ZPL print requests.
sequenceDiagram
participant W as Web App
participant N as Ngrok Endpoint
participant L as Local Print Server
participant P as Network Printer
W->>N: Trigger Event
N->>L: Forward Request
L->>W: Request ZPL Download
W-->>L: Send ZPL Data
L->>P: Send Print Job
P-->>L: Print Confirmation
-
Install dependencies:
npm install -
Start the server:
npm startFor development with auto-restart:
npm run dev -
Expose via ngrok
ngrok http 4321 -
Define the printers and work centers in
/src/config.ts
Accepts a print request with ZPL callback URL and optional work center ID.
Request Body:
{
"url": "https://example.com/zpl-data",
"workCenterId": "WC123" // Optional
}You can also send raw ZPL:
{
"zpl": "^XA^FX Top section with logo, name and address.^CF0,60^FO50,50^GB100,100,100^FS^FO75,75^FR^GB100,100,100^FS^FO93,93^GB40,40,40^FS^FO220,50^FDIntershipping, Inc.^FS^CF0,30^FO220,115^FD1000 Shipping Lane^FS^FO220,155^FDShelbyville TN 38102^FS^FO220,195^FDUnited States (USA)^FS^FO50,250^GB700,3,3^FS^XZ"
}Using curl:
curl -X POST http://localhost:4321/print \
-H "Content-Type: application/json" \
-d '{"url": "https://localhost:3000/file/receipt/cv7ms3i2i0l4uedgh390/labels.zpl", "workCenterId": "1"}'