expo-escpos
Version:
A comprehensive Expo module for ESC/POS thermal printer integration. Supports text formatting, image printing, and receipt generation for 58mm and 80mm thermal printers. Features include text alignment, font styling (bold, italic, underline), image render
61 lines • 2.33 kB
TypeScript
/**
* Supported printer models.
* - "58": 58mm (384px width)
* - "80": 80mm (576px width)
*/
export type PrinterModel = "58" | "80";
/**
* Configuration for rendering images to ESC/POS.
* @property model - Printer model ("58" or "80")
*/
export type ReceiptConfig = {
model: PrinterModel;
};
/**
* Function signature for rendering images to ESC/POS commands.
* @param config - Printer configuration
* @param imageBase64s - Array of base64-encoded image strings
* @returns ESC/POS command data as Uint8Array
*/
export type RenderImagesType = (config: ReceiptConfig, imageBase64s: string[]) => Uint8Array;
/**
* Options for converting HTML to images for ESC/POS.
* @property model - Printer model ("58" or "80")
* @property maxHeightToBreak - Optional: max height in pixels before breaking into multiple images (default: 1600)
*/
export type HtmlToImagesOptions = {
model: PrinterModel;
maxHeightToBreak?: number;
};
/**
* Function signature for converting HTML to ESC/POS commands.
*
* @param html - HTML string to convert. To print a QR code or barcode, use:
* <div data-type="qrcode" data-text="https://example.com" data-size="150"></div>
* <div data-type="barcode" data-text="123456789" data-width="200" data-height="80"></div>
*
* Custom attributes:
* - data-type: "qrcode" or "barcode" (required)
* - data-text: Content to encode (required)
* - data-size: QR code size in px (QR only, optional)
* - data-error-correction: QR error correction (QR only, optional)
* - data-width: Barcode width in px (Barcode only, optional)
* - data-height: Barcode height in px (Barcode only, optional)
*
* @param config - Options for rendering
* @returns Promise resolving to ESC/POS command data as Uint8Array
*/
export type RenderHtmlToImagesType = (html: string, config: HtmlToImagesOptions) => Promise<Uint8Array>;
/**
* Native module interface for Expo ESC/POS.
*/
export interface ExpoEscposModule {
PrinterModel: PrinterModel;
HtmlToImagesOptions: HtmlToImagesOptions;
renderImages: RenderImagesType;
renderHtmlToImages: RenderHtmlToImagesType;
}
declare const ExpoEscpos: ExpoEscposModule;
export declare const renderImages: RenderImagesType, renderHtmlToImages: RenderHtmlToImagesType;
export default ExpoEscpos;
//# sourceMappingURL=index.d.ts.map