UNPKG

react-epson-epos-sdk

Version:

React library for managing Epson printers with ePOS SDK support.

65 lines (64 loc) 2.85 kB
import { PrinterAlign, PrinterCutType, PrinterTextFont } from "./Printer.enums"; import { AddSymbolOptions, AddTextOptions, TextSize, TextStyle } from "./Printer.types"; import { PaperSize } from "../providers/PrinterProvider.enum"; export declare class Printer { private static readonly TIMEOUT; private static readonly HEARTBEAT_XML; private printerIp; private paperSize; private textFont; private textSize; private textStyle; private cursorX; private xmlChunks; constructor(printerIp: string, paperSize: PaperSize); addXmlChunk: (xmlChunk: string) => void; setXmlChunks: (xmlChunks: string[]) => void; getXmlChunks: () => string[]; private reset; addText(text: string, { rightPadding, addNewLine, alignRight, capitalize }?: AddTextOptions): void; addNewLine(): void; setTextFont(font: PrinterTextFont): void; setTextStyle({ reverse, ul, em, color }: Partial<TextStyle>): void; setTextSize(textSize: TextSize): void; setTextAlign(align: PrinterAlign): void; addFeedLine(line: number): void; addCut(type?: PrinterCutType): void; /** * Adds a 2D barcode symbol to the print buffer in XML format. * * @param {string} data - The content/data to encode within the symbol. * * @param {Object} options - Configuration options for the symbol. * @param {PrintSymbolType} options.type - The type of 2D code to print (e.g. QR Code, PDF417, etc.). * @param {AllowedPrintSymbolLevel} options.level - Error correction level or symbol quality level, * depending on the barcode type. * @param {number} [options.width] - Optional. Specifies the width of each module (square block) in dots. * * - The valid range is: * - **QR Code**: 1 to 16 (default = 3) * - **PDF417**: 2 to 8 (default = 3) * - **Aztec/DataMatrix/GS1 DataBar**: 2 to 16 or 2 to 8 depending on type * - **MaxiCode**: Ignored * * @param {number} [options.height] - Optional. Specifies the height of each module in dots. * * - Only applies to **PDF417**, range: 2 to 8 (default = 3). For other types, height is ignored. * * @param {number} [options.size] - Optional. Size-specific attribute depending on symbol type: * * - **PDF417**: Specifies number of codewords per row (default = 0) * - **GS1 DataBar (Expanded Stacked)**: Specifies maximum width (default = 0 for auto) * - **Others (QR Code, MaxiCode, Aztec, DataMatrix)**: Ignored * * @returns {void} */ addSymbol(data: string, { type, level, width, height, size }: AddSymbolOptions): void; addHorizontalLine(): void; toXml(): string; checkOnline(): Promise<boolean>; send(): Promise<void>; private escapeXml; private sendRequest; private getCharactersPerLine; }