/** * TSPL Driver * TSC Printer Language driver for label/barcode printers * * TSPL is commonly used in thermal transfer label printers (TSC, Zebra, etc.) */ /** * Label size configuration */ export interface LabelSize { /** Label width in mm */ width: number; /** Label height in mm */ height: number; /** Gap between labels in mm (default: 3) */ gap?: number; } /** * Text position and style */ export interface TextOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Font size (1-8, default: 2) */ font?: number; /** Rotation (0, 90, 180, 270, default: 0) */ rotation?: 0 | 90 | 180 | 270; /** Horizontal multiplier (1-10, default: 1) */ xMultiplier?: number; /** Vertical multiplier (1-10, default: 1) */ yMultiplier?: number; } /** * Barcode options */ export interface BarcodeOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Barcode type */ type: '128' | '39' | 'EAN13' | 'EAN8' | 'UPCA' | 'QRCODE'; /** Height in dots (default: 100) */ height?: number; /** Narrow bar width (default: 2) */ narrow?: number; /** Wide bar width (default: 4) */ wide?: number; /** Show human-readable text (default: true) */ showText?: boolean; /** Rotation (0, 90, 180, 270, default: 0) */ rotation?: 0 | 90 | 180 | 270; } /** * QR Code options */ export interface QRCodeOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Error correction level (L, M, Q, H, default: M) */ eccLevel?: 'L' | 'M' | 'Q' | 'H'; /** Cell width (1-10, default: 6) */ cellWidth?: number; /** Mode (A=Auto, M=Manual, default: A) */ mode?: 'A' | 'M'; /** Rotation (0, 90, 180, 270, default: 0) */ rotation?: 0 | 90 | 180 | 270; } /** * Box/Rectangle options */ export interface BoxOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Width in dots */ width: number; /** Height in dots */ height: number; /** Line thickness (default: 2) */ thickness?: number; } /** * Line options */ export interface LineOptions { /** Start X position in dots */ x1: number; /** Start Y position in dots */ y1: number; /** End X position in dots */ x2: number; /** End Y position in dots */ y2: number; /** Line thickness (default: 2) */ thickness?: number; } /** * TSPL Driver for label printers * * @example * ```typescript * const tspl = new TsplDriver(); * * const commands = tspl * .size(60, 40) * .gap(3) * .clear() * .text('Product Name', { x: 50, y: 50, font: 3 }) * .barcode('1234567890', { x: 50, y: 100, type: '128' }) * .print(1) * .getBuffer(); * ``` */ export declare class TsplDriver { private commands; private readonly logger; private dpi; /** * Set printer DPI (dots per inch) * @param dpi - DPI value (203 or 300) */ setDPI(dpi: 203 | 300): this; /** * Convert mm to dots */ mmToDots(mm: number): number; /** * Convert dots to mm */ dotsToMm(dots: number): number; /** * Set label size * @param width - Label width in mm * @param height - Label height in mm */ size(width: number, height: number): this; /** * Set gap between labels * @param gap - Gap size in mm * @param offset - Offset in mm (default: 0) */ gap(gap: number, offset?: number): this; /** * Set print speed * @param speed - Speed level (1-10) */ speed(speed: number): this; /** * Set print density * @param density - Density level (0-15) */ density(density: number): this; /** * Set print direction * @param direction - 0=normal, 1=reversed */ direction(direction: 0 | 1): this; /** * Clear image buffer */ clear(): this; /** * Add text to label * @param content - Text content * @param options - Text options */ text(content: string, options: TextOptions): this; /** * Add barcode to label * @param content - Barcode content * @param options - Barcode options */ barcode(content: string, options: BarcodeOptions): this; /** * Add QR code to label * @param content - QR code content * @param options - QR code options */ qrcode(content: string, options: QRCodeOptions): this; /** * Draw a box/rectangle * @param options - Box options */ box(options: BoxOptions): this; /** * Draw a line * @param options - Line options */ line(options: LineOptions): this; /** * Fill a rectangular area * @param x - X position * @param y - Y position * @param width - Width * @param height - Height */ bar(x: number, y: number, width: number, height: number): this; /** * Reverse a rectangular area (white becomes black and vice versa) * @param x - X position * @param y - Y position * @param width - Width * @param height - Height */ reverse(x: number, y: number, width: number, height: number): this; /** * Print the label * @param copies - Number of copies (default: 1) * @param sets - Number of sets (default: 1) */ print(copies?: number, sets?: number): this; /** * Feed labels * @param count - Number of labels to feed */ feed(count?: number): this; /** * Cut paper (if cutter available) */ cut(): this; /** * Beep the buzzer */ beep(): this; /** * Home the print head */ home(): this; /** * Escape special characters in string */ private escapeString; /** * Get all commands as string */ getCommands(): string; /** * Get commands as buffer for sending to printer */ getBuffer(): Uint8Array; /** * Clear all commands */ reset(): this; }