UNPKG

webzlp

Version:

A small library using WebUSB to print labels on label printers.

76 lines 4.79 kB
import { DocumentBuilder } from './Document.js'; import * as Util from '../Util/index.js'; import * as Cmds from '../Commands/index.js'; export interface ILabelDocumentBuilder extends DocumentBuilder<ILabelDocumentBuilder>, ILabelActionCommandBuilder, ILabelPositionCommandBuilder, ILabelContentCommandBuilder { } export declare class LabelDocumentBuilder extends DocumentBuilder<ILabelDocumentBuilder> implements ILabelDocumentBuilder { readonly docType: LabelDocumentType; get commandReorderBehavior(): Cmds.CommandReorderBehavior; constructor(config?: Cmds.PrinterConfig, docType?: LabelDocumentType); clearImageBuffer(): ILabelDocumentBuilder; addPrintCmd(count?: number, additionalDuplicateOfEach?: number): ILabelDocumentBuilder; addCutNowCommand(): ILabelDocumentBuilder; startNewLabel(): ILabelDocumentBuilder; setOffset(horizontal: number, vertical?: number): ILabelDocumentBuilder; setLabelHomeOffsetDots(horizontalOffsetInDots: number, verticalOffsetInDots: number): this; addOffset(horizontal: number, vertical?: number): ILabelDocumentBuilder; resetOffset(): ILabelDocumentBuilder; addImageFromImageData(imageData: ImageData, imageConversionOptions?: Util.ImageConversionOptions): ILabelDocumentBuilder; addImageFromGRF(image: Util.BitmapGRF, imageConversionOptions?: Util.ImageConversionOptions): ILabelDocumentBuilder; addImageFromSVG(svg: string, widthInDots: number, heightInDots: number, imageConversionOptions?: Util.ImageConversionOptions): Promise<ILabelDocumentBuilder>; addLine(lengthInDots: number, heightInDots: number, color?: Cmds.DrawColor): this; addBox(lengthInDots: number, heightInDots: number, thicknessInDots: number): ILabelDocumentBuilder; } /** Types of label documents to send to printers. See the docs. */ export declare enum LabelDocumentType { /** A form that is only used for one set of commands, then discarded. */ instanceForm = 0, /** A form that is stored in the printer to be re-used. */ storedForm = 1, /** A form that is rendered as an image before being sent to the printer. */ imageForm = 2 } export interface ILabelActionCommandBuilder { /** Add a commant to print a number of the preceding label instructions. Defaults to 1 */ addPrintCmd(count?: number, additionalDuplicateOfEach?: number): ILabelDocumentBuilder; /** Clear the image buffer to prepare for a new label. Usually only at the start of a label. */ clearImageBuffer(): ILabelDocumentBuilder; /** Add a command to cut a label, usually at the end of a label and right before the print command. */ addCutNowCommand(): ILabelDocumentBuilder; /** Begin a new label to be sent as a single batch. */ startNewLabel(): ILabelDocumentBuilder; } export interface ILabelPositionCommandBuilder { /** Set the aboslute offset from the top left position of the label. * * Avoid printing off the edges of a label, which can cause excessive head wear. */ setOffset(horizontal: number, vertical?: number): ILabelDocumentBuilder; /** * Sets the temporary origin offset from the top-left of the label that all * other offsets are calculated from. Only applies to current label. * * Avoid printing off the edges of a label, which can cause excessive head wear. */ setLabelHomeOffsetDots(horizontalOffsetInDots: number, verticalOffsetInDots: number): ILabelDocumentBuilder; /** Add a relative offset to the current offset from the top left position of the label. * * Avoid printing off the edges of a label, which can cause excessive head wear. */ addOffset(horizontal: number, vertical?: number): ILabelDocumentBuilder; /** Resets the offset back to origin (top left of label) */ resetOffset(): ILabelDocumentBuilder; } export interface ILabelContentCommandBuilder { /** Add an ImageData object as an image to the label */ addImageFromImageData(imageData: ImageData, imageConversionOptions?: Util.ImageConversionOptions): ILabelDocumentBuilder; /** Add a bitmap GRF image to the label */ addImageFromGRF(image: Util.BitmapGRF): ILabelDocumentBuilder; /** Add an SVG image to the label, rendered to the given width and height. */ addImageFromSVG(svg: string, widthInDots: number, heightInDots: number, imageConversionOptions?: Util.ImageConversionOptions): Promise<ILabelDocumentBuilder>; /** Draw a line from the current offset for the length and height. */ addLine(lengthInDots: number, heightInDots: number, color?: Cmds.DrawColor): ILabelDocumentBuilder; /** Draw a box from the current offset. */ addBox(lengthInDots: number, heightInDots: number, thicknessInDots: number): ILabelDocumentBuilder; } //# sourceMappingURL=LabelDocument.d.ts.map