zpl-js-helper
Version:
A package that is intended to help with the creation of ZPL labels and templates using JS, with scalable text sizes to prevent overflow and overlap of text.
85 lines (73 loc) • 2.39 kB
text/typescript
declare enum PrintDensity {
"8dpmm" = 8
}
declare class Size {
heightInDots: number;
widthInDots: number;
constructor(widthInDots: number, heightInDots: number);
}
interface SectionComponent {
sectionKey: string;
generateZpl(values: string[]): string;
}
declare class Template {
dotsPerMM: PrintDensity;
size: Size;
sections: SectionComponent[];
constructor(widthInMM: number, heightInMM: number, dotsPerMM?: PrintDensity);
generateTestZpl(): string;
addZPLSection(zplSection: SectionComponent): void;
getSections(): SectionComponent[];
}
declare class Origin {
originXInDots: number;
originYInDots: number;
constructor(orginXInDots: number, orginYInDots: number);
}
declare class TextLine {
text: string;
constructor(text: string);
}
type FontFamily = "C" | "0" | "A";
declare class Padding {
top: number;
bottom: number;
left: number;
right: number;
constructor(top: number, bottom: number, left: number, right: number);
totalX(): number;
totalY(): number;
}
declare class TextSection implements SectionComponent {
fontFamily: FontFamily;
padding: Padding;
origin: Origin;
size: Size;
sectionKey: string;
border: string;
borderThickness: number;
orientation: "portrait" | "landscape";
defaultFontSize: number;
textAlignment: "J" | "L" | "C" | "R";
constructor(fontFamily: FontFamily, size: Size, origin: Origin, sectionKey: string, border?: string, // Defaulting to 'none' if no border is specified
borderThickness?: number, // Default border thickness is 2
padding?: Padding, orientation?: "portrait" | "landscape", textAlignment?: "J" | "L" | "C" | "R", fontSize?: number);
generateZpl(values?: string[]): string;
private generateSectionBorders;
private generateText;
private processText;
private calculateStringLengthRelativeToCharacters;
private processTextUpdated;
private breakUpLines;
}
type SectionRecord = {
[key: string]: string[];
};
declare class LabelBuilder {
private template;
private records;
constructor(template: Template, records: SectionRecord[]);
generateZPL(): string;
private generateSectionZPL;
}
export { type FontFamily, LabelBuilder, Origin, Padding, PrintDensity, type SectionComponent, type SectionRecord, Size, Template, TextLine, TextSection };