import { IPrinterDriver, IQrOptions } from '../types'; /** * ESC/POS driver options */ export interface EscPosOptions { /** Use the new EncodingService for better GBK support (default: true) */ useEncodingService?: boolean; /** Show warnings for unsupported characters (default: true) */ showEncodingWarnings?: boolean; /** Fallback character for unsupported characters (default: '?') */ fallbackChar?: string; } /** * ESC/POS thermal printer driver * * Implements the standard ESC/POS command set used by most thermal receipt printers. * Supports text, images, QR codes, and paper control commands. * * @example * ```typescript * const driver = new EscPos(); * const commands = [ * ...driver.init(), * ...driver.text('Hello World!'), * ...driver.feed(2), * ...driver.cut() * ]; * ``` */ export declare class EscPos implements IPrinterDriver { private readonly logger; private readonly encodingService; private readonly useEncodingService; /** * Creates a new EscPos driver instance * @param options - Driver options */ constructor(options?: EscPosOptions); /** * Initializes the printer * Sends ESC @ command to reset printer to default state * * @returns Array of command buffers */ init(): Uint8Array[]; /** * Generates text print command * * @param content - Text content to print * @param encoding - Text encoding (default: 'GBK') * @returns Array of command buffers * * @example * ```typescript * driver.text('你好世界', 'GBK'); * ``` */ text(content: string, encoding?: string): Uint8Array[]; /** * Generates line feed command * * @param lines - Number of lines to feed (default: 1) * @returns Array of command buffers * * @example * ```typescript * driver.feed(3); // Feed 3 lines * ``` */ feed(lines?: number): Uint8Array[]; /** * Generates paper cut command * * @returns Array of command buffers * * @example * ```typescript * driver.cut(); * ``` */ cut(): Uint8Array[]; /** * Generates image print command * Uses Floyd-Steinberg dithering for better quality * * @param data - RGBA pixel data * @param width - Image width in pixels * @param height - Image height in pixels * @returns Array of command buffers * * @example * ```typescript * const imageData = new Uint8Array(width * height * 4); // RGBA * driver.image(imageData, 200, 100); * ``` */ image(data: Uint8Array, width: number, height: number): Uint8Array[]; /** * Generates QR code print command * * @param content - QR code content (URL, text, etc.) * @param options - QR code options * @returns Array of command buffers * * @example * ```typescript * driver.qr('https://example.com', { * model: 2, * size: 8, * errorCorrection: 'M' * }); * ``` */ qr(content: string, options?: IQrOptions): Uint8Array[]; /** * ESC/POS: Open cash drawer (钱箱控制) * Sends ESC p command to trigger cash drawer kick-out * * @param pin - Cash drawer pin (0 or 1, default: 0) * @returns Array of command buffers */ openCashDrawer(pin?: number): Uint8Array[]; /** * ESC/POS: Sound buzzer (蜂鸣器) * Sends ESC B command to activate the printer's built-in buzzer * * @param times - Number of beeps (1-9, default: 3) * @param duration - Duration in ms (default: 50) * @returns Array of command buffers */ beep(times?: number, duration?: number): Uint8Array[]; /** * ESC/POS: Self test (自检) * Sends ESC i command to print a self-test page and return status * * @returns Array of command buffers */ selfTest(): Uint8Array[]; /** * ESC/POS: Get printer status (状态查询) * Sends DLE EOT n commands to query printer, offline, error, and paper status * * @returns Array of command buffers (4 status queries) */ getStatus(): Uint8Array[]; /** * ESC/POS: Set character code page (代码页设置) * Sends ESC t command to select character code page * * @param codePage - Code page number (0-255) * @returns Array of command buffers */ setCodePage(codePage: number): Uint8Array[]; /** * ESC/POS: Set left margin (左边界设置) * Sends ESC l command to set left margin in characters * * @param n - Number of characters from left edge * @returns Array of command buffers */ setLeftMargin(n: number): Uint8Array[]; /** * ESC/POS: Set print area width (打印区域宽度) * Sends ESC W command to set print width in characters * * @param n - Width in characters * @returns Array of command buffers */ setPrintWidth(n: number): Uint8Array[]; }