UNPKG

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

58 lines 2.49 kB
/** * Expo ESC/POS - Convert HTML to ESC/POS commands for thermal printers. * * Main features: * - Convert HTML (with QR/barcode tags) to ESC/POS commands for image printing * - Supports Vietnamese and other complex characters by rendering as images * - Supports both 58mm and 80mm printer models * * @module expo-escpos * * @section Custom HTML Tag Attributes * * To print QR codes and barcodes, add special attributes to your HTML tags: * * **QR Code Tag Example:** * <div * data-type="qrcode" * data-text="https://example.com" // (required) The text or URL to encode * data-size="150" // (optional) Size in pixels (default: 150) * data-error-correction="M" // (optional) Error correction: "L", "M", "Q", "H" (default: "M") * ></div> * * **Barcode Tag Example:** * <div * data-type="barcode" * data-text="123456789" // (required) The text to encode * data-width="200" // (optional) Width in pixels (default: 200) * data-height="80" // (optional) Height in pixels (default: width/2) * ></div> * * **Attribute Reference:** * - `data-type` (required): "qrcode" or "barcode". Tells the renderer what to generate. * - `data-text` (required): The content to encode in the QR code or barcode. If omitted, uses the element's text content. * - `data-size` (QR only, optional): Size of the QR code in pixels. Default: 150. * - `data-error-correction` (QR only, optional): Error correction level for QR code. "L", "M", "Q", or "H". Default: "M". * - `data-width` (Barcode only, optional): Width of the barcode in pixels. Default: 200. * - `data-height` (Barcode only, optional): Height of the barcode in pixels. Default: width/2. * * @example * // Print a QR code: * const html = ` * <div data-type="qrcode" data-text="https://example.com" data-size="150"></div> * `; * const data = await renderHtmlToImages(html, { model: "80" }); * // Send 'data' to your printer * * // Print a barcode: * const html2 = ` * <div data-type="barcode" data-text="123456789" data-width="200" data-height="80"></div> * `; * const data2 = await renderHtmlToImages(html2, { model: "80" }); * // Send 'data2' to your printer */ import { requireNativeModule } from "expo"; const ExpoEscpos = requireNativeModule("ExpoEscpos"); export const { renderImages, renderHtmlToImages } = ExpoEscpos; export default ExpoEscpos; //# sourceMappingURL=index.js.map