/** * ZPL Driver * Zebra Printer Language driver for Zebra label printers * * ZPL is the industry standard for industrial label printing */ /** * ZPL Label size configuration */ export interface ZplLabelSize { /** Label width in dots */ width: number; /** Label height in dots */ height: number; /** Label gap in dots (default: 0) */ gap?: number; } /** * Text format options */ export interface ZplTextOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Font name (default: 0 for built-in) */ font?: string; /** Font rotation: N=0, R=90, I=270, B=180 (default: N) */ rotation?: 'N' | 'R' | 'I' | 'B'; /** Horizontal magnification (1-10, default: 1) */ xMultiplier?: number; /** Vertical magnification (1-10, default: 1) */ yMultiplier?: number; /** Field orientation: N=normal, R=rotated, I=inverted, B=bottom-up */ orientation?: 'N' | 'R' | 'I' | 'B'; } /** * Barcode options */ export interface ZplBarcodeOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Barcode type: 128, 39, 93, EAN13, EAN8, UPCE, CODE51, etc. */ type: '128' | '39' | '93' | 'EAN13' | 'EAN8' | 'UPCA' | 'UPCE' | 'CODE51' | 'MSI' | 'PLESSEY'; /** Barcode height in dots (default: 50) */ height?: number; /** Show human-readable text (default: Y) */ showText?: 'Y' | 'N'; /** Check digit: Y=validate, N=no check (default: Y) */ checkDigit?: 'Y' | 'N'; /** Interpretation line: Y=print, N=omit (default: Y) */ interpretLine?: 'Y' | 'N'; /** Interpretation line above: Y=above, N=below (default: N) */ interpretLineAbove?: 'Y' | 'N'; } /** * QR Code options */ export interface ZplQRCodeOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Model: 2 (default) or 1 */ model?: 1 | 2; /** Magnification factor 1-10 (default: 4) */ magnification?: number; /** Error correction level: L(~7%), M(~15%), Q(~25%), H(~30%) */ errorCorrection?: 'L' | 'M' | 'Q' | 'H'; } /** * Box/Rectangle options */ export interface ZplBoxOptions { /** X position in dots */ x: number; /** Y position in dots */ y: number; /** Width in dots */ width: number; /** Height in dots */ height: number; /** Border thickness (default: 2) */ borderThickness?: number; /** Corner rounding (0-10, default: 0) */ cornerRounding?: number; } /** * ZPL Driver for Zebra label printers * * @example * ```typescript * const zpl = new ZplDriver(); * * const commands = zpl * .startFormat() * .labelHome(10, 10) * .text('Product Name', { x: 50, y: 50 }) * .barcode('1234567890', { x: 50, y: 150, type: '128' }) * .qrcode('https://example.com', { x: 300, y: 50 }) * .print() * .getCommands(); * ``` */ export declare class ZplDriver { private commands; private readonly logger; /** * Initialize ZPL driver with default settings */ constructor(); /** * Start label format (^XA) */ startFormat(): this; /** * End label format (^XZ) */ endFormat(): this; /** * Set label home position * @param x - X position in dots * @param y - Y position in dots */ labelHome(x: number, y: number): this; /** * Set field data (^FD) * @param content - Field content */ fieldData(content: string): this; /** * Set field origin * @param x - X position in dots * @param y - Y position in dots */ fieldOrigin(x: number, y: number): this; /** * Set print width * @param width - Width in dots */ printWidth(width: number): this; /** * Set label length * @param length - Length in dots */ labelLength(length: number): this; /** * Set label gap * @param gap - Gap in dots */ labelGap(gap: number): this; /** * Set print quantity * @param quantity - Number of labels */ quantity(quantity: number): this; /** * Add text to label * @param content - Text content * @param options - Text options */ text(content: string, options?: ZplTextOptions): this; /** * Add text with explicit field origin * @param content - Text content * @param x - X position * @param y - Y position * @param font - Font name (default: 0) * @param rotation - Rotation */ textAt(content: string, x: number, y: number, font?: string, rotation?: 'N' | 'R' | 'I' | 'B'): this; /** * Use built-in font * @param content - Text content * @param x - X position * @param y - Y position * @param height - Character height (40-400) * @param width - Character width (30-300) */ font(content: string, x: number, y: number, height?: number, width?: number): this; /** * Add scalable font * @param content - Text content * @param x - X position * @param y - Y position * @param fontName - Font name (e.g., "0" for built-in, or loaded font name) * @param fontHeight - Height multiplier * @param fontWidth - Width multiplier */ scalableText(content: string, x: number, y: number, fontName?: string, fontHeight?: number, fontWidth?: number): this; /** * Add barcode * @param content - Barcode content * @param options - Barcode options */ barcode(content: string, options: ZplBarcodeOptions): this; /** * Add EAN-13 barcode * @param content - Barcode content (12 or 13 digits) * @param x - X position * @param y - Y position * @param height - Barcode height */ ean13(content: string, x?: number, y?: number, height?: number): this; /** * Add QR code * @param content - QR code content * @param options - QR code options */ qrcode(content: string, options?: ZplQRCodeOptions): this; /** * Add rectangle/border * @param options - Box options */ box(options: ZplBoxOptions): this; /** * Add line * @param x1 - Start X * @param y1 - Start Y * @param x2 - End X * @param y2 - End Y * @param thickness - Line thickness */ line(x1: number, y1: number, x2: number, y2: number, thickness?: number): this; /** * Add circle * @param x - Center X * @param y - Center Y * @param diameter - Diameter in dots * @param borderThickness - Border thickness */ circle(x: number, y: number, diameter: number, borderThickness?: number): this; /** * Add diagonal line * @param x - Start X * @param y - Start Y * @param width - Width * @param height - Height * @param thickness - Line thickness */ diagonal(x: number, y: number, width: number, height: number, thickness?: number): this; /** * Add ellipse * @param x - Center X * @param y - Center Y * @param width - Width * @param height - Height * @param borderThickness - Border thickness */ ellipse(x: number, y: number, width: number, height: number, borderThickness?: number): this; /** * Add image from raw bitmap using ZPL ^GFA (Graphic Field) command. * The bitmap should be 1-bit (monochrome) data where each bit represents a pixel. * @param x - X position in dots * @param y - Y position in dots * @param width - Image width in pixels * @param height - Image height in pixels * @param bitmap - 1-bit monochrome bitmap data (MSB first, row-major) */ image(x: number, y: number, width: number, height: number, bitmap: Uint8Array): this; /** * Set darkness/print density * @param value - Darkness value (0-30, default: 15) */ setDarkness(value?: number): this; /** * Set print speed * @param speed - Speed: 1=slowest, 2-5=medium, 6-13=fast, 14=max */ setSpeed(speed: number): this; /** * Print configuration label (useful for testing) */ printConfigLabel(): this; /** * Calibrate sensors */ calibrate(): this; /** * Reset printer */ reset(): 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 */ resetCommands(): this; /** * Print label (end format) */ print(quantity?: number): this; /** * Escape special characters in field data */ private escapeField; }