BOOST.CloudPrinter
A cloud printing client application that subscribes to an MQTT topic for print jobs and routes them to local system printers. It bridges remote/cloud print requests to physical printers, supporting multiple document formats.
Architecture
MQTT Broker
↓ (subscribe to topic)
Main.java (MqttCallback)
↓ (parse JSON message)
PrinterUtils
↓ (route by MIME type)
┌───────┬───────┬──────┬──────┐
│ PDF │ ZPL │ Text │ Image│
└───┬───┴───┬───┴──┬───┴──┬───┘
↓ ↓ ↓ ↓
javax.print API / TCP Socket (port 9100)
↓
Local PrinterPrerequisites
- Java 8+
- MQTT Broker connectivity
- Local printers accessible via Java Print Service
- For ZPL label printers: network access to printer on port 9100
Configuration
config.properties
properties
broker_uri=tcp://p-s01-mqtt-01.westbahr.net:1883
username=nimpos
password=****
printer_topic=label/danieln| Property | Description |
|---|---|
broker_uri | MQTT broker connection URI |
username | MQTT authentication username |
password | MQTT authentication password |
printer_topic | MQTT topic to subscribe to for print jobs |
Message Format
Incoming MQTT Message (JSON)
json
{
"printername": "HP_LaserJet_Pro",
"base64data": "JVBERi0xLjQK...",
"type": "application/pdf"
}| Field | Description |
|---|---|
printername | Name of the target printer (as registered in the OS) |
base64data | Base64-encoded file content |
type | MIME type determining the print handler |
Supported MIME Types
| MIME Type | Handler | Description |
|---|---|---|
application/pdf | printPDF() | PDF documents via PDFBox + javax.print |
application/zpl | printZPL() | Zebra label printer format via TCP socket |
text/plain | printText() | Plain text via javax.print |
image/png | printImage() | PNG images via javax.print |
image/jpg | printImage() | JPEG images via javax.print |
image/gif | printImage() | GIF images via javax.print |
Print Processing
- MQTT message arrives on the subscribed topic
- JSON payload is parsed to extract printer name, data, and type
- Base64 data is decoded to bytes
- MIME type is matched to the appropriate print handler
- Printer is resolved by name from the system's available printers
- Document is sent to the printer
ZPL (Label Printers)
ZPL jobs are sent directly via TCP socket to port 9100 on the printer, bypassing the Java Print Service. Supports feed-and-cut commands for label printers.
Debug Mode
Run with --debug or -d flag to write decoded files to disk instead of printing:
bash
java -jar Printer.jar --debugStatus Indicators
The application displays a small UI window with:
- Green checkmark — connected and operational
- Red X — error or connection lost (auto-reconnects)
Dependencies
| Dependency | Version | Purpose |
|---|---|---|
paho.mqttv3 | 1.0.2 | MQTT client |
pdfbox | 2.0.7 | PDF rendering for print |
batik-* | 1.7 | SVG status display |
Running
bash
java -jar Printer.jarThe application connects to the MQTT broker, subscribes to the configured topic, and waits for print jobs. It auto-reconnects on connection loss.