UNPKG

sunmi-device-sdk

Version:

JavaScript SDK for Sunmi card readers and printers

131 lines (130 loc) 4.6 kB
/** * Sunmi Printer API * Provides methods to interact with Sunmi thermal printers */ import { PrintAlignment, BarcodeTextPosition, PrinterStatus } from './types'; export declare class SunmiPrinter { /** * Initialize the printer * @returns Promise resolving when printer is initialized */ static init(): Promise<void>; /** * Perform printer self-check * @returns Promise resolving with self-check result */ static selfCheck(): Promise<void>; /** * Get printer serial number * @returns Promise resolving to serial number */ static getSerialNumber(): Promise<string>; /** * Get printer firmware version * @returns Promise resolving to firmware version */ static getVersion(): Promise<string>; /** * Check if printer is available * @returns Promise resolving to true if printer exists */ static hasPrinter(): Promise<boolean>; /** * Get printed paper length * @returns Promise resolving to length in pixels */ static getPrintedLength(): Promise<number>; /** * Feed paper (line wrap) * @param count Number of lines to feed * @returns Promise resolving when operation completes */ static feedPaper(count: number): Promise<void>; /** * Send raw ESC/POS commands * @param base64Data Base64-encoded raw data * @returns Promise resolving when data is sent */ static sendRawData(base64Data: string): Promise<void>; /** * Set text alignment * @param alignment Alignment option (LEFT, CENTER, RIGHT) * @returns Promise resolving when alignment is set */ static setAlignment(alignment: PrintAlignment): Promise<void>; /** * Set font typeface * @param typeface Font name * @returns Promise resolving when font is set */ static setFontName(typeface: string): Promise<void>; /** * Set font size * @param fontSize Font size in points * @returns Promise resolving when font size is set */ static setFontSize(fontSize: number): Promise<void>; /** * Print text with specific font * @param text Text to print * @param typeface Font name * @param fontSize Font size * @returns Promise resolving when text is printed */ static printTextWithFont(text: string, typeface: string, fontSize: number): Promise<void>; /** * Print text in columns * @param columns Array of column text * @param widths Array of column widths * @param alignments Array of column alignments * @returns Promise resolving when columns are printed */ static printColumns(columns: string[], widths: number[], alignments: PrintAlignment[]): Promise<void>; /** * Print a bitmap image * @param base64Data Base64-encoded image data * @param width Image width in pixels * @param height Image height in pixels * @returns Promise resolving when image is printed */ static printBitmap(base64Data: string, width: number, height: number): Promise<void>; /** * Print a barcode * @param data Barcode data * @param symbology Barcode type (e.g., 'CODE128', 'QR', 'EAN13') * @param width Width in pixels * @param height Height in pixels * @param textPosition Text position relative to barcode * @returns Promise resolving when barcode is printed */ static printBarcode(data: string, symbology: string, width: number, height: number, textPosition: BarcodeTextPosition): Promise<void>; /** * Print a QR code * @param data QR code data * @param moduleSize Size of each QR module (1-16) * @param errorLevel Error correction level (0-3) * @returns Promise resolving when QR code is printed */ static printQRCode(data: string, moduleSize: number, errorLevel: number): Promise<void>; /** * Print text without encoding * @param text Text to print * @returns Promise resolving when text is printed */ static printOriginalText(text: string): Promise<void>; /** * Print text with current settings * @param text Text to print * @returns Promise resolving when text is printed */ static printText(text: string): Promise<void>; /** * Start listening to printer status changes * @param callback Callback function receiving status updates */ static startStatusListener(callback: (status: PrinterStatus) => void): void; /** * Stop listening to printer status changes */ static stopStatusListener(): void; }