Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllLabels []Label
AllLabels contains all predefined label configurations.
var AllModels []Model
AllModels contains all predefined printer models configurations.
Functions ¶
This section is empty.
Types ¶
type BrotherQLRaster ¶
type BrotherQLRaster struct {
Model Model
Data bytes.Buffer
CutAtEnd bool
Dpi600 bool
TwoColorPrinting bool
// contains filtered or unexported fields
}
BrotherQLRaster builds the raster data stream for Brother QL printers.
type ConvertOptions ¶
type ConvertOptions struct {
Cut bool
Dither bool
Compress bool
Red bool
Rotate string // "auto", "0", "90", "180", "270"
Dpi600 bool
Hq bool
Threshold float64
DitherAlgo string // "atkinson", "burkes", "stucki", "sierra2", "sierra3", "sierralite", "floyd_steinberg"
OnWarning func(string)
}
ConvertOptions contains settings for converting images into raster data suitable for the Brother QL printer.
type FormFactor ¶
type FormFactor int
FormFactor specifies the type of label media.
const ( // DieCut represents die-cut labels with fixed size. DieCut FormFactor = iota + 1 // Endless represents continuous tape labels. Endless // RoundDieCut represents round die-cut labels. RoundDieCut // PtouchEndless represents P-touch continuous tape labels. PtouchEndless )
type Label ¶
type Label struct {
Identifier string // e.g., "62", "29x90"
TapeSize [2]int // width, length in mm
FormFactor FormFactor
DotsTotal [2]int // total dots [width, length]
DotsPrintable [2]int // printable dots [width, length]
OffsetR int // right margin alignment offset
FeedMargin int // feed margin in dots
RestrictedToModels []string // allowed models, if any
Color Color
}
Label represents the specifications of a label type.
type LabelPrinter ¶ added in v0.1.0
type LabelPrinter struct {
// contains filtered or unexported fields
}
LabelPrinter manages connection and printing to a Brother QL printer.
func NewLabelPrinter ¶ added in v0.1.0
func NewLabelPrinter(ctx context.Context, model, backend, id string) (*LabelPrinter, error)
NewLabelPrinter creates a new LabelPrinter. It attempts an initial connection but does not return an error if the connection fails (e.g., printer is off), allowing the printer object to be used once it's powered on.
func (*LabelPrinter) Close ¶ added in v0.1.4
func (p *LabelPrinter) Close() error
Close closes the connection to the printer after a short delay to allow the printer to process buffered commands.
func (*LabelPrinter) IsLive ¶ added in v0.1.5
func (p *LabelPrinter) IsLive(ctx context.Context) bool
IsLive checks if the printer connection is available.
func (*LabelPrinter) Print ¶ added in v0.1.0
func (p *LabelPrinter) Print(ctx context.Context, images []image.Image, opts PrintOptions) error
Print converts and sends the images to the printer.
type Model ¶
type Model struct {
Identifier string // e.g., "QL-700", "QL-820NWB"
MinMaxLengthDots [2]int // [min, max] dots for continuous length
MinMaxFeed [2]int // [min, max] feed length
NumberBytesPerRow int // Usually 90 for QL-series, 162 for wider models
AdditionalOffsetR int // Right margin offset
ModeSetting bool // Supports ESC/P and raster mode switching
Cutting bool // Supports automatic cutting
ExpandedMode bool // Supports expanded mode commands
Compression bool // Supports raster line compression
TwoColor bool // Supports Red/Black printing (e.g., QL-800 series)
NumInvalidateBytes int // Number of zero bytes to send for invalidation
}
Model describes the capabilities and parameters of a Brother QL printer model.
type PrintOptions ¶ added in v0.1.0
type PrintOptions struct {
Label string // The label size identifier (e.g., "62", "29x90")
ConvertOptions
}
PrintOptions contains options for printing.
func NewDefaultOptions ¶ added in v0.1.0
func NewDefaultOptions(label string) PrintOptions
NewDefaultOptions creates a default PrintOptions with recommended settings.