Expand description
Rust driver for Brother QL series label printers
Convert images to Brother QL Raster Command binary data and print labels via USB or kernel drivers.
§Features
- Print directly via USB (
UsbConnection) or Linux kernel driver (KernelConnection) - Compile to file for network printing or debugging
- Multiple label types - Continuous rolls and die-cut labels in various sizes
- Two-color printing - Black/red support on compatible printers
- Full status monitoring - Check errors, media type, and printer state
§Supported Printers
Brother QL series: 5xx (QL-560, QL-570, QL-580N), 6xx (QL-600, QL-650TD), 7xx (QL-700, QL-710W, QL-720NW), 8xx (QL-800, QL-810W, QL-820NWB)
See printer module for complete list and testing status.
§Feature Flags
usb(optional) - Enables USB printing via therusbcrate. ProvidesUsbConnectionandUsbConnectionInfo.serde(optional) - Enables serialization support forMediaandCutBehavior.
The crate has no default features. Basic print job compilation and KernelConnection
work without any features enabled.
§Quick Start
§USB Printing (requires usb feature)
use brother_ql::{
connection::{PrinterConnection, UsbConnection, UsbConnectionInfo},
media::Media,
printer::PrinterModel,
printjob::PrintJob,
};
// Connect to a specific printer model
let info = UsbConnectionInfo::from_model(PrinterModel::QL820NWB);
let mut connection = UsbConnection::open(info)?;
// Create and print a label
let img = image::open("label.png")?;
let job = PrintJob::from_image(img, Media::C62)?;
connection.print(job)?;§Kernel Driver Printing (Linux, no features required)
use brother_ql::{
connection::{KernelConnection, PrinterConnection},
media::Media,
printjob::PrintJob,
};
let mut connection = KernelConnection::open("/dev/usb/lp0")?;
let img = image::open("label.png")?;
let job = PrintJob::from_image(img, Media::C62)?;
connection.print(job)?;§Compile to File (no features required)
use brother_ql::{media::Media, printjob::PrintJob};
use std::{fs::File, io::Write};
let img = image::open("label.png")?;
let job = PrintJob::from_image(img, Media::C62)?;
// Compile to binary data
let data = job.compile();
// Save to file (can be sent via network: `nc printer-ip 9100 < output.bin`)
File::create("output.bin")?.write_all(&data)?;§Choosing Media
Media types determine label dimensions and behavior:
- Continuous rolls (
Cprefix likeC62) - Cut to any length - Die-cut labels (
Dprefix likeD17x54) - Pre-cut, fixed dimensions - Two-color (
Rsuffix likeC62R) - Black/red printing support
All media types require 720 pixels wide images at 300 DPI. Height varies by media type.
See media module for complete details.
§Print Job Configuration
Use PrintJobBuilder for advanced customization:
let job = PrintJobBuilder::new(Media::C62)
.add_label(img1) // Add first image
.add_label(img2) // Add second image
.copies(5) // Print 5 copies of each
.high_dpi(false) // 300 DPI (default)
.quality_priority(true) // Quality over speed (default)
.cut_behavior(CutBehavior::CutEvery(2)) // Cut every 2 labels
.build()?;See PrintJob and PrintJobBuilder for defaults and all options.
§Status Monitoring
Check printer status, errors, and media information:
let status = connection.get_status()?;
println!("Model: {:?}", status.model);
println!("Media: {}mm wide", status.media_width);
if status.has_errors() {
eprintln!("Errors: {:?}", status.errors);
}See status module for complete status information.
§References
- Official Raster Command Reference
- Images are processed using the
imagecrate
Modules§
- connection
- Printer connection types and traits
- error
- Error types for the Brother QL library
- media
- Media type definitions and settings
- printer
- Printer model definitions and USB configuration
- printjob
- Print job creation and configuration
- status
- Printer status information parsing and types
- test_
labels - Module for creating example labels for all supported media types