react-epson-epos-sdk
Version:
React library for managing Epson printers with ePOS SDK support.
73 lines (72 loc) • 3.36 kB
TypeScript
import { PrinterAlign, PrinterCutType, PrinterTextFont } from "./Printer.enums";
import { AddSymbolOptions, AddTextOptions, TextSize, TextStyle } from "./Printer.types";
import { PaperSize } from "../providers/PrinterProvider.enum";
import type { PrinterConnectionOptions } from "../providers/printer.types";
export declare class Printer {
private static readonly DEFAULT_HEARTBEAT_TIMEOUT_MS;
private static readonly DEFAULT_PRINT_TIMEOUT_MS;
private static readonly HEARTBEAT_XML;
private printerIp;
private paperSize;
private connectionOptions;
private textFont;
private textSize;
private textStyle;
private cursorX;
private xmlChunks;
constructor(printerIp: string, paperSize: PaperSize, options?: PrinterConnectionOptions);
addXmlChunk: (xmlChunk: string) => void;
setXmlChunks: (xmlChunks: string[]) => void;
getXmlChunks: () => string[];
/** Synchronously returns and clears the buffer (plus cursor/style state) so a job can be snapshotted atomically before any `await`. */
consumeXmlChunks: () => 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(chunks?: string[]): string;
checkOnline(): Promise<boolean>;
sendChunks: (chunks: string[]) => Promise<void>;
send(): Promise<void>;
private escapeXml;
private httpGateKey;
private sendRequest;
private postToPrinter;
private getCharactersPerLine;
}