webzlp
Version:
A small library using WebUSB to print labels on label printers.
110 lines • 6.51 kB
TypeScript
import { IDocument, DocumentBuilder } from './Document.js';
import * as Util from '../Util/index.js';
import * as Conf from '../Configs/index.js';
import * as Cmds from '../Commands/index.js';
/** A series of printer commands that results in configuration changes. */
export interface IConfigDocumentBuilder extends DocumentBuilder<IConfigDocumentBuilder>, IPrinterBasicCommandBuilder, IPrinterConfigBuilder, IPrinterLabelConfigBuilder {
}
/** Builder to generate a configuration to apply to a printer. */
export declare class ConfigDocumentBuilder extends DocumentBuilder<IConfigDocumentBuilder> implements IConfigDocumentBuilder {
get commandReorderBehavior(): Cmds.CommandReorderBehavior;
constructor(config?: Cmds.PrinterConfig);
private _doSave;
finalize(): IDocument;
clearImageBuffer(): IConfigDocumentBuilder;
rebootPrinter(): IDocument;
queryConfiguration(): IConfigDocumentBuilder;
printConfiguration(): IConfigDocumentBuilder;
queryStatus(): IConfigDocumentBuilder;
setDarknessConfig(darknessPercent: Conf.DarknessPercent): this;
setPrintDirection(upsideDown?: boolean): this;
setPrintSpeed(speed: Conf.PrintSpeed, mediaSlewSpeed?: Conf.PrintSpeed): this;
autosenseLabelLength(): IDocument;
setBackfeedAfterTakenMode(mode: Conf.BackfeedAfterTaken): this;
setLabelDimensions(widthInInches: number, lengthInInches?: number, gapLengthInInches?: number): this;
setLabelDimensionsDots(widthInDots: number, lengthInDots?: number, gapLengthInDots?: number): this;
setLabelHomeOffsetDots(horizontalOffsetInDots: number, verticalOffsetInDots: number): this;
setLabelPrintOriginOffsetCommand(horizontalOffsetInDots: number, verticalOffsetInDots: number): this;
setLabelMediaToContinuous(mediaLengthInInches: number, formGapInInches?: number): IConfigDocumentBuilder;
setLabelMediaToWebGapSense(labelLengthInInches: number, labelGapInInches: number): IConfigDocumentBuilder;
setLabelMediaToMarkSense(labelLengthInInches: number, blackLineThicknessInInches: number, blackLineOffsetInInches: number): IConfigDocumentBuilder;
}
export interface IPrinterBasicCommandBuilder {
/** Clear the image buffer and prepare for a new set of Cmds. */
clearImageBuffer(): IConfigDocumentBuilder;
/** Simulate turning the printer off and back on. Must be the final command. */
rebootPrinter(): IDocument;
/** Get any error messages from the printer. */
queryStatus(): IConfigDocumentBuilder;
}
export interface IPrinterConfigBuilder {
/** Query the printer for its config details. */
queryConfiguration(): IConfigDocumentBuilder;
/** Print the configuration directly on labels. Must be final command. */
printConfiguration(): IConfigDocumentBuilder;
}
export interface IPrinterLabelConfigBuilder {
/** Set the darkness of the printer in the stored configuration. */
setDarknessConfig(darknessPercent: Conf.DarknessPercent): IConfigDocumentBuilder;
/** Set the direction labels print out of the printer. */
setPrintDirection(upsideDown?: boolean): IConfigDocumentBuilder;
/** Set the speed at which the labels print. */
setPrintSpeed(speed: Conf.PrintSpeed): IConfigDocumentBuilder;
/**
* Set the size of the labels in the printer.
*
* Omit length and gap if an autosense was or will be run. Both must be provided
* to set the length and gap manually, otherwise the length will be ignored. This
* is usually only necessary when using continuous media, see the documentation.
*
* Note that different printers often have slightly different values, copying
* values between printers may have unintended effects.
*/
setLabelDimensions(widthInInches: number, lengthInInches?: number, gapLengthInInches?: number): IConfigDocumentBuilder;
/**
* Set the size of the labels in the printer, sized in dots. Dots are printer DPI specific.
*
* Omit length and gap if an autosense was or will be run. Both must be provided
* to set the length and gap manually, otherwise the length will be ignored. This
* is usually only necessary when using continuous media, see the documentation.
*
* Note that different printers often have slightly different values, copying
* values between printers may have unintended effects.
*/
setLabelDimensionsDots(widthInDots: number, lengthInDots?: number, gapLengthInDots?: number): IConfigDocumentBuilder;
/**
* Sets the temporary origin offset from the top-left of the label that all
* other offsets are calculated from. Only applies to current label.
*
* Use this to fine-tune the alignment of your printer to your label stock.
*
* Avoid printing off the edges of a label, which can cause excessive head wear.
*/
setLabelHomeOffsetDots(horizontalOffsetInDots: number, verticalOffsetInDots: number): IConfigDocumentBuilder;
/** Sets the retained origin offset from the top-left of the label that all
* other offets are calculated from. Applies to all labels until a printer reset
* or power cycle.
*
* May or may not be stored depending on printer firmware.
*
* Avoid printing off the edges of a label, which can cause excessive head wear.
*/
setLabelPrintOriginOffsetCommand(horizontalOffsetInDots: number, verticalOffsetInDots: number): IConfigDocumentBuilder;
/** Run the autosense operation to get label length. Must be last command. */
autosenseLabelLength(): IDocument;
/** Set the backfeed behavior after cut/take of label. */
setBackfeedAfterTakenMode(mode: Conf.BackfeedAfterTaken): IConfigDocumentBuilder;
/** Sets the media type to continuous (gapless) media. */
setLabelMediaToContinuous(labelLengthInDots: number): IConfigDocumentBuilder;
/** Sets the media type to web gap sensing media. It's recommended to run autosense after this. */
setLabelMediaToWebGapSense(labelLengthInDots: number, labelGapInDots: number): IConfigDocumentBuilder;
/** Sets the media type to mark sensing media. */
setLabelMediaToMarkSense(labelLengthInDots: number, blackLineThicknessInDots: number, blackLineOffset: number): IConfigDocumentBuilder;
}
/** Error indicating setting a config value failed. */
export declare class UnsupportedPrinterConfigError extends Util.WebZlpError {
constructor(settingName: string, settingError: string);
settingName: string;
settingError: string;
}
//# sourceMappingURL=ConfigDocument.d.ts.map