Skip to content

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 Printer

Prerequisites

  • 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
PropertyDescription
broker_uriMQTT broker connection URI
usernameMQTT authentication username
passwordMQTT authentication password
printer_topicMQTT topic to subscribe to for print jobs

Message Format

Incoming MQTT Message (JSON)

json
{
  "printername": "HP_LaserJet_Pro",
  "base64data": "JVBERi0xLjQK...",
  "type": "application/pdf"
}
FieldDescription
printernameName of the target printer (as registered in the OS)
base64dataBase64-encoded file content
typeMIME type determining the print handler

Supported MIME Types

MIME TypeHandlerDescription
application/pdfprintPDF()PDF documents via PDFBox + javax.print
application/zplprintZPL()Zebra label printer format via TCP socket
text/plainprintText()Plain text via javax.print
image/pngprintImage()PNG images via javax.print
image/jpgprintImage()JPEG images via javax.print
image/gifprintImage()GIF images via javax.print
  1. MQTT message arrives on the subscribed topic
  2. JSON payload is parsed to extract printer name, data, and type
  3. Base64 data is decoded to bytes
  4. MIME type is matched to the appropriate print handler
  5. Printer is resolved by name from the system's available printers
  6. 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 --debug

Status Indicators

The application displays a small UI window with:

  • Green checkmark — connected and operational
  • Red X — error or connection lost (auto-reconnects)

Dependencies

DependencyVersionPurpose
paho.mqttv31.0.2MQTT client
pdfbox2.0.7PDF rendering for print
batik-*1.7SVG status display

Running

bash
java -jar Printer.jar

The application connects to the MQTT broker, subscribes to the configured topic, and waits for print jobs. It auto-reconnects on connection loss.