/** * CPCL Driver * PCL commands for Compact Print Language - HP/Honeywell/Toddler printers * * CPCL is commonly used in mobile/portable thermal printers */ /** * CPCL page size presets */ export type CPCLPageSize = 'A4' | 'A5' | 'LETTER' | '4X6' | '4X2' | '4X4' | '2.25X1.25' | 'CUSTOM'; /** * CPCL Text options */ export interface CpclTextOptions { /** X position in dots */ x?: number; /** Y position in dots */ y?: number; /** Font type: 0-6 (0=OCR, 1=OCR-B, 2=CG Triumvirate, etc.) */ font?: number; /** Horizontal multiplier (1-8) */ xMulti?: number; /** Vertical multiplier (1-8) */ yMulti?: number; /** Rotation: 0, 90, 180, 270 */ rotation?: 0 | 90 | 180 | 270; } /** * CPCL Barcode options */ export interface CpclBarcodeOptions { /** X position in dots */ x?: number; /** Y position in dots */ y?: number; /** Barcode type */ type: '128' | '39' | 'EAN13' | 'EAN8' | 'UPCA' | 'UPCE' | 'MSI' | 'PLESSEY' | 'PDF417' | 'DATAMATRIX' | 'QR'; /** Barcode height in dots (default: 50) */ height?: number; /** Wide bar width for 39 (default: 2) */ wide?: number; /** Narrow bar width (default: 1) */ narrow?: number; /** Show human-readable text (default: true) */ readable?: boolean; } /** * CPCL QR Code options */ export interface CpclQRCodeOptions { /** X position in dots */ x?: number; /** Y position in dots */ y?: number; /** Model (default: 2) */ model?: 1 | 2; /** Error correction level: L, M, Q, H */ errorCorrection?: 'L' | 'M' | 'Q' | 'H'; /** Cell size (default: 4) */ cellSize?: number; } /** * CPCL Line options */ export interface CpclLineOptions { /** Start X position */ x1: number; /** Start Y position */ y1: number; /** End X position */ x2: number; /** End Y position */ y2: number; /** Line width/thickness */ width?: number; } /** * CPCL Box options */ export interface CpclBoxOptions { /** X position */ x: number; /** Y position */ y: number; /** Width */ width: number; /** Height */ height: number; /** Border thickness */ thickness?: number; } /** * CPCL Driver for HP, Honeywell, and Toddler portable printers * * @example * ```typescript * const cpcl = new CpclDriver(); * * const commands = cpcl * .pageStart() * .text('Hello World!', { x: 50, y: 50 }) * .barcode('1234567890', { x: 50, y: 150, type: '128' }) * .qrcode('https://example.com', { x: 300, y: 50 }) * .pageEnd() * .getCommands(); * ``` */ export declare class CpclDriver { private commands; private readonly logger; private pageWidth; private pageHeight; /** * Initialize CPCL driver * @param width - Page width in dots * @param height - Page height in dots (0 = continuous) */ constructor(width?: number, height?: number); /** * Set page size * @param width - Width in dots * @param height - Height in dots (0 = continuous) */ setPageSize(width: number, height?: number): this; /** * Use standard page size * @param size - Preset size name */ usePageSize(size: CPCLPageSize): this; /** * Start a new page */ pageStart(): this; /** * End current page */ pageEnd(): this; /** * Form feed to next label */ formFeed(): this; /** * Set line print mode * @param font - Font number (0-6) * @param xMulti - Horizontal multiplier * @param yMulti - Vertical multiplier */ setLinePrint(font?: number, xMulti?: number, yMulti?: number): this; /** * Set text font * @param font - Font: 0=OCR, 1=OCR-B, 2=CG Triumvirate Bold, 3-6=Various sizes * @param xMulti - Horizontal multiplier (1-8) * @param yMulti - Vertical multiplier (1-8) * @param rotation - Rotation angle */ setFont(font?: number, xMulti?: number, yMulti?: number, rotation?: 0 | 90 | 180 | 270): this; /** * Add text at current position * @param content - Text content */ text(content: string): this; /** * Add positioned text * @param content - Text content * @param options - Text options */ textAt(content: string, options: CpclTextOptions): this; /** * Add text using legacy command * @param content - Text content * @param x - X position * @param y - Y position * @param font - Font number */ legacyText(content: string, x: number, y: number, font?: number): this; /** * Add barcode at position * @param content - Barcode content * @param options - Barcode options */ barcode(content: string, options: CpclBarcodeOptions): this; /** * Add QR code * @param content - QR code content * @param options - QR options */ qrcode(content: string, options?: CpclQRCodeOptions): this; /** * Add 2D barcode (PDF417 or DataMatrix) * @param content - Content * @param type - Type: PDF417 or DATAMATRIX * @param x - X position * @param y - Y position * @param height - Height */ twoDBarcode(content: string, type: 'PDF417' | 'DATAMATRIX', x?: number, y?: number, height?: number): this; /** * Add line * @param options - Line options */ line(options: CpclLineOptions): this; /** * Add box/rectangle * @param options - Box options */ box(options: CpclBoxOptions): this; /** * Add inverse area (white on black) * @param x - X position * @param y - Y position * @param width - Width * @param height - Height */ inverse(x: number, y: number, width: number, height: number): this; /** * Set print density * @param density - Density value (-50 to +50) */ setDensity(density: number): this; /** * Set speed * @param speed - Speed: 2-6 (2=50%, 3=75%, 4=100%, 5=125%, 6=150%) */ setSpeed(speed: number): this; /** * Cut paper (if cutter installed) */ cut(): this; /** * Partial cut */ partialCut(): this; /** * Feed and cut */ feedCut(): this; /** * Sound beep * @param count - Number of beeps * @param duration - Duration in 10ms units */ beep(count?: number, duration?: number): this; /** * Add logo/image * @param x - X position * @param y - Y position * @param logoName - Stored logo name */ logo(x: number, y: number, logoName: string): this; /** * Download logo to printer memory (macro/form storage). * Encodes bitmap using CPCL CG (Compressed Graphic) command. * The bitmap should be 1-bit monochrome data. * @param logoName - Name to store logo as * @param bitmap - 1-bit monochrome bitmap data (MSB first, row-major) * @param options - Optional width and height (will be inferred from bitmap size if omitted) */ downloadLogo(logoName: string, bitmap: Uint8Array, options?: { width?: number; height?: number; }): this; /** * Print stored logo * @param logoName - Logo name * @param x - X position * @param y - Y position */ printLogo(logoName: string, x?: number, y?: number): this; /** * Get all commands as string */ getCommands(): string; /** * Get commands as buffer for sending to printer */ getBuffer(): Uint8Array; /** * Get raw command list */ getCommandList(): string[]; /** * Clear all commands */ reset(): this; /** * Get page width */ getPageWidth(): number; /** * Escape special characters in text */ private escapeText; }