On this page & docs navigation
Examples · best practices

Everyday scenarios, ready to copy

Every example uses only channels that genuinely exist in the client (REST /api/command, convenience endpoints, native WebSocket /ws, the terminal remote channel).No JS wrapper assumed; the examples use the client's default address and port - adjust printer names to the devices actually on your machine. For other languages, see Multi-language integration.

Logistics waybill (template + data + paper-size matching)

waybill

E-commerce warehousing and courier work: 100×150 waybills mixed with A4, routed automatically by paper-size tolerance.

REST / convenience endpoints

# General command endpoint: template + data (real)
curl -X POST http://127.0.0.1:19861/api/command -H 'Content-Type: application/json' -d '{
  "cmd": "TemplatePrint",
  "html": "<div>Recipient: {{name}} {{phone}}<br>{{addr}}</div>",
  "data": { "name":"Zhang Wei", "addr":"100 Tiyu West Road, Tianhe District, Guangzhou", "phone":"13800138000" },
  "printer": "HP LaserJet Pro M404",
  "paperKind": "100x150"
}'
# Result: Result JSON (code=200 means success; on failure read error)

WebSocket / remote channel

# The same structure over native WebSocket (long connection for batches)
ws://127.0.0.1:19861/ws
→ {"cmd":"TemplatePrint","html":"<div>Recipient: {{name}}</div>","data":{"name":"Zhang Wei"},"paperKind":"100x150"}
← {"code":200,"error":"success","data":{}}

Thermal receipt (raw ESC/POS)

receipt

Store and campus order printing: raw commands sent straight to the printer, barcodes and QR codes included.

REST / convenience endpoints

# Convenience endpoint (real)
curl -X POST http://127.0.0.1:19861/api/escpos -H 'Content-Type: application/json' -d '{
  "printer": "EPSON TM-T82III",
  "text": "Litchio receipt sample  Total: ¥18.00",
  "barcode": { "data":"6901234567892", "type":"code128" }
}'

WebSocket / remote channel

# Or over /ws: {"cmd":"PrintEscPos","printer":"EPSON TM-T82III","text":"Litchio receipt sample"}
# Result: Result JSON

Government form printing (background alignment + copies)

gov

Government offices and service halls: certificate form printing, with copy-count and layout control.

REST / convenience endpoints

# General command endpoint: form background + copies
curl -X POST http://127.0.0.1:19861/api/command -H 'Content-Type: application/json' -d '{
  "cmd": "TemplatePrint",
  "html": "<div style='position:absolute;top:40mm;left:30mm'>{{name}}</div>",
  "data": { "name": "Zhang Wei" },
  "copies": 1,
  "printer": "HP LaserJet Pro M404"
}'
# Route to a specific counter printer (GetPrinterList enumerates capabilities first)

WebSocket / remote channel

# Check printer capabilities before sending
→ {"cmd":"GetPrinterList"}
→ After choosing the target machine: {"cmd":"TemplatePrint","printer":"HP LaserJet Pro M404"}
# Receipts are logged: Result + queue status via GetQueue

School and copy shops (per-page billing + pickup)

shop

Self-service printing; scheduling and online payment come from the cloud service.

REST / convenience endpoints

# Batch queueing (by page or by copy)
curl -X POST http://127.0.0.1:19861/api/print -H 'Content-Type: application/json' -d '{
  "target": "D:/handouts/chapter-1.pdf",
  "copies": 3,
  "duplex": "duplexlong",
  "printer": "HP LaserJet Pro M404"
}'
# Pickup: check job status with GetQueue → paper comes out when done

WebSocket / remote channel

# Spread peak-hour load across several printers (each terminal keeps its own /ws connection, routed by device)
# Cloud service: scheduled time slots + payment release

Print from a link (all parameters in one call)

netfile

Your business system supplies a download link - no need to download first; orientation, copies, duplex and mono are all set in one call.

REST / convenience endpoints

# General command endpoint: network PDF + common print parameters
curl -X POST http://127.0.0.1:19861/api/command -H 'Content-Type: application/json' -d '{
  "cmd": "PrintFile",
  "target": "https://files.example.com/reports/monthly.pdf",
  "printer": "HP LaserJet Pro M404",
  "orientation": "landscape",
  "copies": 3,
  "duplex": "duplexlong",
  "color": "monochrome",
  "collate": true,
  "paperKind": "A4"
}'
# Result: Result JSON, with data.engine giving the file category (e.g. pdf / image / office)

WebSocket / remote channel

# Dynamic links with no extension go through the same endpoint
→ {"target":"https://files.example.com/export?id=8891","copies":2}
# The client identifies the type by response file name / file-header signature / content type

Without cmd: auto detection

auto

Just supply the content and let the client decide whether it is a network file, a local file or a piece of inline content.

REST / convenience endpoints

# Omitting cmd means auto by default
curl -X POST http://127.0.0.1:19861/api/command -H 'Content-Type: application/json' -d '{
  "target": "https://files.example.com/orders/waybill?id=8891",
  "copies": 2
}'
# Returns data.auto: { resolved, category, detectedBy }
# You can also supply content directly: { "content": "<html><h1>Pickup slip</h1></html>", "filename": "ticket.html" }

WebSocket / remote channel

# The explicit form is equivalent: cmd = "Auto" / "AutoPrint" / "PrintFile"
→ {"cmd":"Auto","base64":"JVBERi0xLjQK","copies":1}
# data URIs are supported too: data:application/pdf;base64,JVBERi0xLjQK

Note: scheduled printing and online payment are provided by the cloud service; for more scenario details, see Solutions.

From job to paper

Wire any one of the commands above into your business system, and the client takes care of the rest - layout, routing and paper output. Below is a short film of continuous paper printing.

  • Check /api/commands first to confirm command names
  • Use Result.code to judge success or failure
  • For batches, use the /ws long connection
Continuous paper printing (free-to-use stock footage)

Wire the examples into your own system

Every scenario above can start with a single command that works, then grow into batch jobs. For other languages, see "Multi-language integration".

  • Verify connectivity with one command first
  • Confirm the result code before scaling to batches
  • Long connections suit peak-hour load spreading
Overhead view of a shared development desk with laptops
Many languages, many terminals, one set of print commands