Desktop Print Server
The Desktop Print Server is a Node.js daemon that runs locally on cashier or packers' workstations. It receives secure WebSocket print payloads from your WooCommerce web dashboard and routes them directly to default system printers.
This bypasses browser print dialog popups, enabling silent, automated printing.
1. WebSocket Hook Communication
When you click Print in the WooCommerce admin interface:
- payload Assembly:
auto-print.jsreads your visual template properties and wraps data inside a JSON socket payload:{ "action": "print", "printer": "Zebra_ZD420", "mode": "zpl", "content": "^XA^FO50,50^A0N,36,20^FDProduct Name^FS^BY3^FO50,100^BCN,100,Y,N,N^FD12345678^FS^XZ", "copies": 2 } - Socket Request: The browser sends this payload via a secure WebSocket connection:
const socket = new WebSocket("wss://localhost:8080"); socket.onopen = () => socket.send(JSON.stringify(payload)); - print daemon routing: The local server processes the incoming payload and forwards the content string (either ZPL instructions or image base64 bytes) to the OS printing stack using native Node library bindings.
2. SSL Certificate Generation & Trust (Critical Step)
Modern browsers enforce secure contexts. HTTPS pages cannot make network calls to HTTP endpoints. Therefore, the local WebSocket server must communicate over SSL (wss://).
To generate and trust the SSL certificates:
Step 1: Run the Cert Generator
Inside your desktop server directory, run:
npm run cert
This generates:
certificate/localhost.key(Private key)certificate/localhost.crt(Public certificate)
Step 2: Register Certificate in OS Trust Store
- Windows:
- Double-click
localhost.crt. - Click Install Certificate...
- Select Local Machine and click Next.
- Select Place all certificates in the following store and browse to Trusted Root Certification Authorities.
- Click Finish and confirm the security warning.
- Double-click
- macOS:
- Open Keychain Access.
- Drag
localhost.crtinto the System keychain. - Double-click the imported certificate, expand Trust, and change "When using this certificate" to Always Trust.
- Linux: Copy the cert to
/usr/local/share/ca-certificates/and run:sudo update-ca-certificates
3. Printing Modes: ZPL vs Image Canvas
Choose your printing mode based on your printer hardware:
ZPL Mode (Zebra Programming Language)
Recommended for Zebra, TSC, Honeywell, and other industrial thermal printers.
- How it works: The plugin converts HTML/CSS coordinates into standard ZPL vector commands.
- Benefits:
- Lightweight payloads (a few bytes compared to megabytes of images).
- Extremely fast transmission over WebSockets.
- Razor-sharp, vector-quality barcodes that scan flawlessly.
Image Canvas Mode (Raster)
Recommended for Dymo, Brother, desktop laser, and standard paper printers.
- How it works: The plugin utilizes
html2canvasinside your browser to render the designed label as a high-density canvas image. - Process: The canvas is exported as a PNG base64 stream and sent to the local server, which uses standard system drivers to render and print the document.
- Drawbacks: Larger print payloads and potential blurring of barcode lines if label dimensions are scaled down in printer settings.
[!CAUTION] Firewall Exceptions: If you are setting up the print server on a remote warehouse machine separate from your computer, ensure your workstation firewall allows TCP traffic on port
8080.