import * as utils from '../tools/utils'; import * as formatters2 from '../tools/formatters'; import { ReceiptConfig } from '../receipt'; import { ConfigurationChunk, imageOptions } from '../tools/formatters'; export type LineSegment = WordSegment & { language?: string; options?: formatters2.chunkOptions; }; /** * Used to store the options supported by the printer language * when generating a word */ export type WordSegment = { debugGroup: string; text: string; style: utils.FontStyle; supportHexValues?: boolean; isFixedWidthFont?: boolean; /** @deprecated */ containsArabicChars?: boolean; fontHeight?: number; fontWidth?: number; lineSpacing?: number; }; /** * Used to store the data of an image, as well as its properties */ export type PrinterImageBase = { imageData: string; imageDataHex?: string; width: number; height: number; rowSizeInBytes?: number; totalSizeInBytes?: number; }; /** * Interface to define all the methods that a printer language should implement * @remarks All printer languages support the following special commands: * - **@#(font)**: changes the text encoding to the one specified. This encoding will be used for all subsequent text printed, * after the command is called. * - **:** - by default, unless specified otherwise, the default character which is used to specify a printer specific command is the colon (**:**) character. * @example @#cp866 - changes the text encoding to cp866 * */ export declare abstract class PrinterLanguage { constructor(); /** The space from the left edge of the paper before printing starts */ defaultLeftMargin: number; /** The height between different rows */ defaultLineSpacing: number; /** The height of the font in pixels */ defaultFontHeight: number; /** The width of the font in pixels */ defaultFontWidth: number; /** The width of the page in pixels (only for HTML) */ defaultPageWidth: number; /** The default font to use */ defaultFont: string; protected lines: any[]; additionalDocumentHeight: number; /** * Used to print a a text line * @param lineSegments - An array of LineSegment objects to be printed */ abstract printLine(lineSegments: Array): void; /** * Used to print an image * @param imageData - The data of the image. * @param width - The width of the image * @param height - The height of the image * @param alignment - How the image is aligned on the page * @param options - additional options for printing the image */ abstract printImage(imageData: Uint8Array, width: number, height: number, alignment: utils.Alignment, options: imageOptions): void; /** * Used to print an image from an array of images * @param images - The array of image to combine * @param width - The width of the new image * @param height - The height of the new image * @param alignment - How the image is aligned on the page * @param options - additional options for printing the image */ abstract printImageRow(images: Array, width: number, height: number, alignment: utils.Alignment, options?: imageOptions): Promise; /** * Used to print a horizontal ruler on the page * @param ruler - The text to be printed as a ruler */ abstract printHorizRuler(ruler: string): void; /** * Generates the final document to be printed. This method should be called after all the other methods have been called, * and will contain all commands for the printer to execute. */ abstract printDocument(): string; abstract printDocumentAsync(): Promise; /** * Used to initialise the printer language * @param config - The new configuration of the receipt */ abstract init(config?: ReceiptConfig): void; /** Used to update the current X and Z coordinates of the printer * @param xCoord - The new X coordinate (used for left/right alignment) * @param zCoord - The new Z coordinate (used for up/down alignment) */ abstract updateCoordinates(xCoord?: number, zCoord?: number): any; /** * Used to change the printer configuration. * * @param printerCfg - The new configuration to apply. If this parameter contains property `printers`, * the configuration will check if there is a specific configuration for the printer type and apply it. * If there is no specific configuration, the properties provided in the chunk will be used. * @param printerType - The type of printer to apply the configuration to */ protected internalChangeConfiguration(printerCfg: ConfigurationChunk, printerType: string): void; abstract printBarcode(barcodeData: string, barcodeType: utils.Barcode, height: number, width: number, offset: number, alignment: utils.Alignment, options?: formatters2.barcodeOptions): void; abstract changeConfiguration(chunk: ConfigurationChunk): void; /** * Used to render a word containing special characters (like arabic) * @param word - The word to be rendered * @param options - How to render the word */ abstract renderWord(word: string, options: formatters2.chunkOptions): string; }