label-printer 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +63 -36
- package/dist/index.d.ts +63 -36
- package/dist/index.js +180 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -91,6 +91,16 @@ type BitmapLike = {
|
|
|
91
91
|
*/
|
|
92
92
|
type BWBitmap = BitmapLike;
|
|
93
93
|
|
|
94
|
+
type Point = {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
};
|
|
98
|
+
type Dimension = {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
};
|
|
102
|
+
type Rotation = 0 | 90 | 180 | 270;
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
105
|
* Interface that should be implemented by a command generator object for each language
|
|
96
106
|
*/
|
|
@@ -144,7 +154,6 @@ declare abstract class TSPLVisualCommand extends TSPLCommand {
|
|
|
144
154
|
constructor(x: number, y: number);
|
|
145
155
|
}
|
|
146
156
|
|
|
147
|
-
type Rotation = 0 | 90 | 180 | 270;
|
|
148
157
|
type Alignment = undefined | "left" | "center" | "right";
|
|
149
158
|
/**
|
|
150
159
|
* Convert an alignemnt string to its number value
|
|
@@ -442,7 +451,6 @@ type index$3_ECCLevel = ECCLevel;
|
|
|
442
451
|
type index$3_GraphicMode = GraphicMode;
|
|
443
452
|
type index$3_LabelDirection = LabelDirection;
|
|
444
453
|
type index$3_QRModel = QRModel;
|
|
445
|
-
type index$3_Rotation = Rotation;
|
|
446
454
|
type index$3_TSPLBarCommand = TSPLBarCommand;
|
|
447
455
|
declare const index$3_TSPLBarCommand: typeof TSPLBarCommand;
|
|
448
456
|
type index$3_TSPLBitmapCommand = TSPLBitmapCommand;
|
|
@@ -481,14 +489,9 @@ type index$3_TSPLVisualCommand = TSPLVisualCommand;
|
|
|
481
489
|
declare const index$3_TSPLVisualCommand: typeof TSPLVisualCommand;
|
|
482
490
|
declare const index$3_alignmentToNumber: typeof alignmentToNumber;
|
|
483
491
|
declare namespace index$3 {
|
|
484
|
-
export { type index$3_Alignment as Alignment, type index$3_AutoManual as AutoManual, type index$3_BarcodeHumanReable as BarcodeHumanReable, type index$3_BarcodeType as BarcodeType, type index$3_ECCLevel as ECCLevel, type index$3_GraphicMode as GraphicMode, type index$3_LabelDirection as LabelDirection, type index$3_QRModel as QRModel,
|
|
492
|
+
export { type index$3_Alignment as Alignment, type index$3_AutoManual as AutoManual, type index$3_BarcodeHumanReable as BarcodeHumanReable, type index$3_BarcodeType as BarcodeType, type index$3_ECCLevel as ECCLevel, type index$3_GraphicMode as GraphicMode, type index$3_LabelDirection as LabelDirection, type index$3_QRModel as QRModel, index$3_TSPLBarCommand as TSPLBarCommand, index$3_TSPLBitmapCommand as TSPLBitmapCommand, index$3_TSPLBlockCommand as TSPLBlockCommand, index$3_TSPLCLSCommand as TSPLCLSCommand, index$3_TSPLCommand as TSPLCommand, index$3_TSPLCommandGroup as TSPLCommandGroup, index$3_TSPLDensityCommand as TSPLDensityCommand, index$3_TSPLDiagonal as TSPLDiagonal, index$3_TSPLDirectionCommand as TSPLDirectionCommand, index$3_TSPLDisplay as TSPLDisplay, index$3_TSPLDownload as TSPLDownload, index$3_TSPLGapCommand as TSPLGapCommand, index$3_TSPLPrintCommand as TSPLPrintCommand, index$3_TSPLQRCommand as TSPLQRCommand, index$3_TSPLRawCommand as TSPLRawCommand, index$3_TSPLSizeCommand as TSPLSizeCommand, index$3_TSPLTextCommand as TSPLTextCommand, index$3_TSPLVisualCommand as TSPLVisualCommand, index$3_alignmentToNumber as alignmentToNumber, _default as commandGenerator };
|
|
485
493
|
}
|
|
486
494
|
|
|
487
|
-
type Point = {
|
|
488
|
-
x: number;
|
|
489
|
-
y: number;
|
|
490
|
-
};
|
|
491
|
-
|
|
492
495
|
type PrinterLanguage = "tspl";
|
|
493
496
|
type UnitSystem = "imperial" | "metric" | "dot";
|
|
494
497
|
|
|
@@ -496,11 +499,13 @@ type index$2_Command = Command;
|
|
|
496
499
|
declare const index$2_Command: typeof Command;
|
|
497
500
|
type index$2_CommandGroup<T extends Command> = CommandGroup<T>;
|
|
498
501
|
declare const index$2_CommandGroup: typeof CommandGroup;
|
|
502
|
+
type index$2_Dimension = Dimension;
|
|
499
503
|
type index$2_Point = Point;
|
|
500
504
|
type index$2_PrinterLanguage = PrinterLanguage;
|
|
505
|
+
type index$2_Rotation = Rotation;
|
|
501
506
|
type index$2_UnitSystem = UnitSystem;
|
|
502
507
|
declare namespace index$2 {
|
|
503
|
-
export { index$2_Command as Command, index$2_CommandGroup as CommandGroup, type index$2_Point as Point, type index$2_PrinterLanguage as PrinterLanguage, type index$2_UnitSystem as UnitSystem, index$3 as tspl };
|
|
508
|
+
export { index$2_Command as Command, index$2_CommandGroup as CommandGroup, type index$2_Dimension as Dimension, type index$2_Point as Point, type index$2_PrinterLanguage as PrinterLanguage, type index$2_Rotation as Rotation, type index$2_UnitSystem as UnitSystem, index$3 as tspl };
|
|
504
509
|
}
|
|
505
510
|
|
|
506
511
|
type Expand<T> = T extends infer O ? {
|
|
@@ -517,6 +522,11 @@ type Font = {
|
|
|
517
522
|
type FontOption = Expand<Partial<Pick<Font, "style" | "weight">> & Pick<Font, "name"> & {
|
|
518
523
|
size: number;
|
|
519
524
|
}>;
|
|
525
|
+
/**
|
|
526
|
+
* The orientation, the label will be printed on. This allows designing a label in the natural orientation, than printing to
|
|
527
|
+
* a label that is rotated in the printer. The rotation is applied to all fields on the label, and it is independent from the rotation of individual fields.
|
|
528
|
+
*/
|
|
529
|
+
type LabelOrientation = "normal" | "left" | "right" | "upside-down";
|
|
520
530
|
|
|
521
531
|
type PrintConfig = {
|
|
522
532
|
dpi: number;
|
|
@@ -539,7 +549,7 @@ declare abstract class Printable {
|
|
|
539
549
|
/**
|
|
540
550
|
* Generates printable command for the given printer. Can be used to obtain a command for fields supported by the package then customizing it before printing
|
|
541
551
|
* @param printer Printer to generate the command. Important because the command is printer language specific
|
|
542
|
-
* @returns A promise for a command. Most commands are
|
|
552
|
+
* @returns A promise for a command. Most commands are synchronous but some may require to access async resources
|
|
543
553
|
*/
|
|
544
554
|
commandForPrinter(printer: Printer, config?: PrintConfig): Promise<Command>;
|
|
545
555
|
/**
|
|
@@ -571,10 +581,11 @@ declare class Label extends Printable {
|
|
|
571
581
|
private fonts;
|
|
572
582
|
private dpi;
|
|
573
583
|
private density;
|
|
584
|
+
private orientation;
|
|
574
585
|
/**
|
|
575
586
|
* List of fields on the label
|
|
576
587
|
*/
|
|
577
|
-
private
|
|
588
|
+
private container;
|
|
578
589
|
private fontCounter;
|
|
579
590
|
private _textWidthCorrectionFactor;
|
|
580
591
|
/**
|
|
@@ -588,6 +599,11 @@ declare class Label extends Printable {
|
|
|
588
599
|
* @param factor Correction factor (default 1.0, typical range 0.9-1.0)
|
|
589
600
|
*/
|
|
590
601
|
setTextWidthCorrectionFactor(factor: number): void;
|
|
602
|
+
/**
|
|
603
|
+
* Change the orientation the label is printed in. This will rotate all fields in the container
|
|
604
|
+
* @param orientation
|
|
605
|
+
*/
|
|
606
|
+
setOrientation(orientation: LabelOrientation): void;
|
|
591
607
|
constructor(width: number, height: number, dimensionUnit?: UnitSystem, dpi?: number, density?: number);
|
|
592
608
|
commandForLanguage(language: PrinterLanguage, config?: PrintConfig): Promise<Command>;
|
|
593
609
|
/**
|
|
@@ -651,26 +667,40 @@ declare class Line extends LabelField {
|
|
|
651
667
|
commandForLanguage(language: PrinterLanguage): Promise<Command>;
|
|
652
668
|
}
|
|
653
669
|
|
|
670
|
+
interface RotatableField {
|
|
671
|
+
setRotation(rotation: Rotation): void;
|
|
672
|
+
getRotation(): Rotation;
|
|
673
|
+
}
|
|
674
|
+
interface PositionedField {
|
|
675
|
+
getPosition(): Point;
|
|
676
|
+
setPosition(position: Point): void;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
declare abstract class RotatableLabelField extends LabelField implements RotatableField {
|
|
680
|
+
protected rotation: Rotation;
|
|
681
|
+
setRotation(rotation: Rotation): void;
|
|
682
|
+
getRotation(): Rotation;
|
|
683
|
+
}
|
|
684
|
+
|
|
654
685
|
/**
|
|
655
686
|
* Presents a piece of text on the label
|
|
656
687
|
*/
|
|
657
|
-
declare class Text extends
|
|
688
|
+
declare class Text extends RotatableLabelField implements PositionedField {
|
|
658
689
|
private readonly content;
|
|
659
690
|
/**
|
|
660
691
|
* X coordinate in dots
|
|
661
692
|
*/
|
|
662
|
-
private
|
|
693
|
+
private x;
|
|
663
694
|
/**
|
|
664
695
|
* Y coordinate in dots
|
|
665
696
|
*/
|
|
666
|
-
private
|
|
697
|
+
private y;
|
|
667
698
|
/**
|
|
668
|
-
* If true, basic html elements will be
|
|
699
|
+
* If true, basic html elements will be interpreted, otherwise the raw string is printed out
|
|
669
700
|
*/
|
|
670
701
|
private readonly formatted;
|
|
671
702
|
private font;
|
|
672
703
|
private type;
|
|
673
|
-
private rotation;
|
|
674
704
|
private context;
|
|
675
705
|
private readonly lineSpacing;
|
|
676
706
|
/**
|
|
@@ -685,6 +715,8 @@ declare class Text extends LabelField {
|
|
|
685
715
|
private height;
|
|
686
716
|
private endsWithBreak;
|
|
687
717
|
constructor(content: string, x: number, y: number, formatted?: boolean);
|
|
718
|
+
setPosition(position: Point): void;
|
|
719
|
+
getPosition(): Point;
|
|
688
720
|
/**
|
|
689
721
|
* Sets the field to single line
|
|
690
722
|
* @param width Max width of the text. Leave it undefined to allow the field to grow
|
|
@@ -702,11 +734,6 @@ declare class Text extends LabelField {
|
|
|
702
734
|
* that is registered on the label using 'registerFont'.
|
|
703
735
|
*/
|
|
704
736
|
setFont(font: FontOption): void;
|
|
705
|
-
/**
|
|
706
|
-
* Set the rotation of the text field. All text commands in this field will be rotated.
|
|
707
|
-
* For multiline text, lines advance perpendicular to the character direction.
|
|
708
|
-
*/
|
|
709
|
-
setRotation(rotation: Rotation): void;
|
|
710
737
|
/** Advance cursor by `amount` along the character direction */
|
|
711
738
|
private advanceChar;
|
|
712
739
|
/** Advance to the next line (reset char axis, advance in line direction) */
|
|
@@ -750,14 +777,13 @@ declare class Text extends LabelField {
|
|
|
750
777
|
private defaultTextWidth;
|
|
751
778
|
}
|
|
752
779
|
|
|
753
|
-
declare class BarCode extends
|
|
780
|
+
declare class BarCode extends RotatableLabelField implements PositionedField {
|
|
754
781
|
private readonly content;
|
|
755
|
-
private
|
|
756
|
-
private
|
|
782
|
+
private x;
|
|
783
|
+
private y;
|
|
757
784
|
private readonly type;
|
|
758
785
|
private readonly height;
|
|
759
786
|
private readonly barWidth;
|
|
760
|
-
private rotation;
|
|
761
787
|
private humanReadable;
|
|
762
788
|
private readonly alignment;
|
|
763
789
|
/**
|
|
@@ -770,24 +796,25 @@ declare class BarCode extends LabelField {
|
|
|
770
796
|
* calculated automatically based on the symbology's standard ratio.
|
|
771
797
|
*/
|
|
772
798
|
constructor(content: string, x: number, y: number, type: BarcodeType, height: number, barWidth?: number);
|
|
773
|
-
setRotation(rotation: Rotation): void;
|
|
774
799
|
setHumanReadable(humanReadable: BarcodeHumanReable): void;
|
|
800
|
+
setPosition(position: Point): void;
|
|
801
|
+
getPosition(): Point;
|
|
775
802
|
commandForLanguage(language: PrinterLanguage, _config?: PrintConfig | undefined): Promise<Command>;
|
|
776
803
|
}
|
|
777
804
|
|
|
778
|
-
declare class Image extends
|
|
805
|
+
declare class Image extends RotatableLabelField implements PositionedField {
|
|
779
806
|
/**
|
|
780
807
|
* X coordinate in dots
|
|
781
808
|
*/
|
|
782
|
-
private
|
|
809
|
+
private x;
|
|
783
810
|
/**
|
|
784
811
|
* Y coordinate in dots
|
|
785
812
|
*/
|
|
786
|
-
private
|
|
813
|
+
private y;
|
|
787
814
|
private readonly image;
|
|
788
|
-
private rotation;
|
|
789
815
|
constructor(x: number, y: number, image: BitmapLike);
|
|
790
|
-
|
|
816
|
+
setPosition(position: Point): void;
|
|
817
|
+
getPosition(): Point;
|
|
791
818
|
commandForLanguage(language: PrinterLanguage, _config?: PrintConfig | undefined): Promise<Command>;
|
|
792
819
|
/**
|
|
793
820
|
* Create an image field for an image
|
|
@@ -801,14 +828,14 @@ declare class Image extends LabelField {
|
|
|
801
828
|
static create(image: string | Blob, x: number, y: number, width?: number, height?: number): Promise<Image>;
|
|
802
829
|
}
|
|
803
830
|
|
|
804
|
-
declare class QRCode extends
|
|
831
|
+
declare class QRCode extends RotatableLabelField implements PositionedField {
|
|
805
832
|
private readonly content;
|
|
806
|
-
private
|
|
807
|
-
private
|
|
833
|
+
private x;
|
|
834
|
+
private y;
|
|
808
835
|
private readonly width;
|
|
809
|
-
private rotation;
|
|
810
836
|
constructor(content: string, x: number, y: number, width: number);
|
|
811
|
-
|
|
837
|
+
setPosition(position: Point): void;
|
|
838
|
+
getPosition(): Point;
|
|
812
839
|
commandForLanguage(language: PrinterLanguage, config?: PrintConfig | undefined): Promise<Command>;
|
|
813
840
|
}
|
|
814
841
|
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,16 @@ type BitmapLike = {
|
|
|
91
91
|
*/
|
|
92
92
|
type BWBitmap = BitmapLike;
|
|
93
93
|
|
|
94
|
+
type Point = {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
};
|
|
98
|
+
type Dimension = {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
};
|
|
102
|
+
type Rotation = 0 | 90 | 180 | 270;
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
105
|
* Interface that should be implemented by a command generator object for each language
|
|
96
106
|
*/
|
|
@@ -144,7 +154,6 @@ declare abstract class TSPLVisualCommand extends TSPLCommand {
|
|
|
144
154
|
constructor(x: number, y: number);
|
|
145
155
|
}
|
|
146
156
|
|
|
147
|
-
type Rotation = 0 | 90 | 180 | 270;
|
|
148
157
|
type Alignment = undefined | "left" | "center" | "right";
|
|
149
158
|
/**
|
|
150
159
|
* Convert an alignemnt string to its number value
|
|
@@ -442,7 +451,6 @@ type index$3_ECCLevel = ECCLevel;
|
|
|
442
451
|
type index$3_GraphicMode = GraphicMode;
|
|
443
452
|
type index$3_LabelDirection = LabelDirection;
|
|
444
453
|
type index$3_QRModel = QRModel;
|
|
445
|
-
type index$3_Rotation = Rotation;
|
|
446
454
|
type index$3_TSPLBarCommand = TSPLBarCommand;
|
|
447
455
|
declare const index$3_TSPLBarCommand: typeof TSPLBarCommand;
|
|
448
456
|
type index$3_TSPLBitmapCommand = TSPLBitmapCommand;
|
|
@@ -481,14 +489,9 @@ type index$3_TSPLVisualCommand = TSPLVisualCommand;
|
|
|
481
489
|
declare const index$3_TSPLVisualCommand: typeof TSPLVisualCommand;
|
|
482
490
|
declare const index$3_alignmentToNumber: typeof alignmentToNumber;
|
|
483
491
|
declare namespace index$3 {
|
|
484
|
-
export { type index$3_Alignment as Alignment, type index$3_AutoManual as AutoManual, type index$3_BarcodeHumanReable as BarcodeHumanReable, type index$3_BarcodeType as BarcodeType, type index$3_ECCLevel as ECCLevel, type index$3_GraphicMode as GraphicMode, type index$3_LabelDirection as LabelDirection, type index$3_QRModel as QRModel,
|
|
492
|
+
export { type index$3_Alignment as Alignment, type index$3_AutoManual as AutoManual, type index$3_BarcodeHumanReable as BarcodeHumanReable, type index$3_BarcodeType as BarcodeType, type index$3_ECCLevel as ECCLevel, type index$3_GraphicMode as GraphicMode, type index$3_LabelDirection as LabelDirection, type index$3_QRModel as QRModel, index$3_TSPLBarCommand as TSPLBarCommand, index$3_TSPLBitmapCommand as TSPLBitmapCommand, index$3_TSPLBlockCommand as TSPLBlockCommand, index$3_TSPLCLSCommand as TSPLCLSCommand, index$3_TSPLCommand as TSPLCommand, index$3_TSPLCommandGroup as TSPLCommandGroup, index$3_TSPLDensityCommand as TSPLDensityCommand, index$3_TSPLDiagonal as TSPLDiagonal, index$3_TSPLDirectionCommand as TSPLDirectionCommand, index$3_TSPLDisplay as TSPLDisplay, index$3_TSPLDownload as TSPLDownload, index$3_TSPLGapCommand as TSPLGapCommand, index$3_TSPLPrintCommand as TSPLPrintCommand, index$3_TSPLQRCommand as TSPLQRCommand, index$3_TSPLRawCommand as TSPLRawCommand, index$3_TSPLSizeCommand as TSPLSizeCommand, index$3_TSPLTextCommand as TSPLTextCommand, index$3_TSPLVisualCommand as TSPLVisualCommand, index$3_alignmentToNumber as alignmentToNumber, _default as commandGenerator };
|
|
485
493
|
}
|
|
486
494
|
|
|
487
|
-
type Point = {
|
|
488
|
-
x: number;
|
|
489
|
-
y: number;
|
|
490
|
-
};
|
|
491
|
-
|
|
492
495
|
type PrinterLanguage = "tspl";
|
|
493
496
|
type UnitSystem = "imperial" | "metric" | "dot";
|
|
494
497
|
|
|
@@ -496,11 +499,13 @@ type index$2_Command = Command;
|
|
|
496
499
|
declare const index$2_Command: typeof Command;
|
|
497
500
|
type index$2_CommandGroup<T extends Command> = CommandGroup<T>;
|
|
498
501
|
declare const index$2_CommandGroup: typeof CommandGroup;
|
|
502
|
+
type index$2_Dimension = Dimension;
|
|
499
503
|
type index$2_Point = Point;
|
|
500
504
|
type index$2_PrinterLanguage = PrinterLanguage;
|
|
505
|
+
type index$2_Rotation = Rotation;
|
|
501
506
|
type index$2_UnitSystem = UnitSystem;
|
|
502
507
|
declare namespace index$2 {
|
|
503
|
-
export { index$2_Command as Command, index$2_CommandGroup as CommandGroup, type index$2_Point as Point, type index$2_PrinterLanguage as PrinterLanguage, type index$2_UnitSystem as UnitSystem, index$3 as tspl };
|
|
508
|
+
export { index$2_Command as Command, index$2_CommandGroup as CommandGroup, type index$2_Dimension as Dimension, type index$2_Point as Point, type index$2_PrinterLanguage as PrinterLanguage, type index$2_Rotation as Rotation, type index$2_UnitSystem as UnitSystem, index$3 as tspl };
|
|
504
509
|
}
|
|
505
510
|
|
|
506
511
|
type Expand<T> = T extends infer O ? {
|
|
@@ -517,6 +522,11 @@ type Font = {
|
|
|
517
522
|
type FontOption = Expand<Partial<Pick<Font, "style" | "weight">> & Pick<Font, "name"> & {
|
|
518
523
|
size: number;
|
|
519
524
|
}>;
|
|
525
|
+
/**
|
|
526
|
+
* The orientation, the label will be printed on. This allows designing a label in the natural orientation, than printing to
|
|
527
|
+
* a label that is rotated in the printer. The rotation is applied to all fields on the label, and it is independent from the rotation of individual fields.
|
|
528
|
+
*/
|
|
529
|
+
type LabelOrientation = "normal" | "left" | "right" | "upside-down";
|
|
520
530
|
|
|
521
531
|
type PrintConfig = {
|
|
522
532
|
dpi: number;
|
|
@@ -539,7 +549,7 @@ declare abstract class Printable {
|
|
|
539
549
|
/**
|
|
540
550
|
* Generates printable command for the given printer. Can be used to obtain a command for fields supported by the package then customizing it before printing
|
|
541
551
|
* @param printer Printer to generate the command. Important because the command is printer language specific
|
|
542
|
-
* @returns A promise for a command. Most commands are
|
|
552
|
+
* @returns A promise for a command. Most commands are synchronous but some may require to access async resources
|
|
543
553
|
*/
|
|
544
554
|
commandForPrinter(printer: Printer, config?: PrintConfig): Promise<Command>;
|
|
545
555
|
/**
|
|
@@ -571,10 +581,11 @@ declare class Label extends Printable {
|
|
|
571
581
|
private fonts;
|
|
572
582
|
private dpi;
|
|
573
583
|
private density;
|
|
584
|
+
private orientation;
|
|
574
585
|
/**
|
|
575
586
|
* List of fields on the label
|
|
576
587
|
*/
|
|
577
|
-
private
|
|
588
|
+
private container;
|
|
578
589
|
private fontCounter;
|
|
579
590
|
private _textWidthCorrectionFactor;
|
|
580
591
|
/**
|
|
@@ -588,6 +599,11 @@ declare class Label extends Printable {
|
|
|
588
599
|
* @param factor Correction factor (default 1.0, typical range 0.9-1.0)
|
|
589
600
|
*/
|
|
590
601
|
setTextWidthCorrectionFactor(factor: number): void;
|
|
602
|
+
/**
|
|
603
|
+
* Change the orientation the label is printed in. This will rotate all fields in the container
|
|
604
|
+
* @param orientation
|
|
605
|
+
*/
|
|
606
|
+
setOrientation(orientation: LabelOrientation): void;
|
|
591
607
|
constructor(width: number, height: number, dimensionUnit?: UnitSystem, dpi?: number, density?: number);
|
|
592
608
|
commandForLanguage(language: PrinterLanguage, config?: PrintConfig): Promise<Command>;
|
|
593
609
|
/**
|
|
@@ -651,26 +667,40 @@ declare class Line extends LabelField {
|
|
|
651
667
|
commandForLanguage(language: PrinterLanguage): Promise<Command>;
|
|
652
668
|
}
|
|
653
669
|
|
|
670
|
+
interface RotatableField {
|
|
671
|
+
setRotation(rotation: Rotation): void;
|
|
672
|
+
getRotation(): Rotation;
|
|
673
|
+
}
|
|
674
|
+
interface PositionedField {
|
|
675
|
+
getPosition(): Point;
|
|
676
|
+
setPosition(position: Point): void;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
declare abstract class RotatableLabelField extends LabelField implements RotatableField {
|
|
680
|
+
protected rotation: Rotation;
|
|
681
|
+
setRotation(rotation: Rotation): void;
|
|
682
|
+
getRotation(): Rotation;
|
|
683
|
+
}
|
|
684
|
+
|
|
654
685
|
/**
|
|
655
686
|
* Presents a piece of text on the label
|
|
656
687
|
*/
|
|
657
|
-
declare class Text extends
|
|
688
|
+
declare class Text extends RotatableLabelField implements PositionedField {
|
|
658
689
|
private readonly content;
|
|
659
690
|
/**
|
|
660
691
|
* X coordinate in dots
|
|
661
692
|
*/
|
|
662
|
-
private
|
|
693
|
+
private x;
|
|
663
694
|
/**
|
|
664
695
|
* Y coordinate in dots
|
|
665
696
|
*/
|
|
666
|
-
private
|
|
697
|
+
private y;
|
|
667
698
|
/**
|
|
668
|
-
* If true, basic html elements will be
|
|
699
|
+
* If true, basic html elements will be interpreted, otherwise the raw string is printed out
|
|
669
700
|
*/
|
|
670
701
|
private readonly formatted;
|
|
671
702
|
private font;
|
|
672
703
|
private type;
|
|
673
|
-
private rotation;
|
|
674
704
|
private context;
|
|
675
705
|
private readonly lineSpacing;
|
|
676
706
|
/**
|
|
@@ -685,6 +715,8 @@ declare class Text extends LabelField {
|
|
|
685
715
|
private height;
|
|
686
716
|
private endsWithBreak;
|
|
687
717
|
constructor(content: string, x: number, y: number, formatted?: boolean);
|
|
718
|
+
setPosition(position: Point): void;
|
|
719
|
+
getPosition(): Point;
|
|
688
720
|
/**
|
|
689
721
|
* Sets the field to single line
|
|
690
722
|
* @param width Max width of the text. Leave it undefined to allow the field to grow
|
|
@@ -702,11 +734,6 @@ declare class Text extends LabelField {
|
|
|
702
734
|
* that is registered on the label using 'registerFont'.
|
|
703
735
|
*/
|
|
704
736
|
setFont(font: FontOption): void;
|
|
705
|
-
/**
|
|
706
|
-
* Set the rotation of the text field. All text commands in this field will be rotated.
|
|
707
|
-
* For multiline text, lines advance perpendicular to the character direction.
|
|
708
|
-
*/
|
|
709
|
-
setRotation(rotation: Rotation): void;
|
|
710
737
|
/** Advance cursor by `amount` along the character direction */
|
|
711
738
|
private advanceChar;
|
|
712
739
|
/** Advance to the next line (reset char axis, advance in line direction) */
|
|
@@ -750,14 +777,13 @@ declare class Text extends LabelField {
|
|
|
750
777
|
private defaultTextWidth;
|
|
751
778
|
}
|
|
752
779
|
|
|
753
|
-
declare class BarCode extends
|
|
780
|
+
declare class BarCode extends RotatableLabelField implements PositionedField {
|
|
754
781
|
private readonly content;
|
|
755
|
-
private
|
|
756
|
-
private
|
|
782
|
+
private x;
|
|
783
|
+
private y;
|
|
757
784
|
private readonly type;
|
|
758
785
|
private readonly height;
|
|
759
786
|
private readonly barWidth;
|
|
760
|
-
private rotation;
|
|
761
787
|
private humanReadable;
|
|
762
788
|
private readonly alignment;
|
|
763
789
|
/**
|
|
@@ -770,24 +796,25 @@ declare class BarCode extends LabelField {
|
|
|
770
796
|
* calculated automatically based on the symbology's standard ratio.
|
|
771
797
|
*/
|
|
772
798
|
constructor(content: string, x: number, y: number, type: BarcodeType, height: number, barWidth?: number);
|
|
773
|
-
setRotation(rotation: Rotation): void;
|
|
774
799
|
setHumanReadable(humanReadable: BarcodeHumanReable): void;
|
|
800
|
+
setPosition(position: Point): void;
|
|
801
|
+
getPosition(): Point;
|
|
775
802
|
commandForLanguage(language: PrinterLanguage, _config?: PrintConfig | undefined): Promise<Command>;
|
|
776
803
|
}
|
|
777
804
|
|
|
778
|
-
declare class Image extends
|
|
805
|
+
declare class Image extends RotatableLabelField implements PositionedField {
|
|
779
806
|
/**
|
|
780
807
|
* X coordinate in dots
|
|
781
808
|
*/
|
|
782
|
-
private
|
|
809
|
+
private x;
|
|
783
810
|
/**
|
|
784
811
|
* Y coordinate in dots
|
|
785
812
|
*/
|
|
786
|
-
private
|
|
813
|
+
private y;
|
|
787
814
|
private readonly image;
|
|
788
|
-
private rotation;
|
|
789
815
|
constructor(x: number, y: number, image: BitmapLike);
|
|
790
|
-
|
|
816
|
+
setPosition(position: Point): void;
|
|
817
|
+
getPosition(): Point;
|
|
791
818
|
commandForLanguage(language: PrinterLanguage, _config?: PrintConfig | undefined): Promise<Command>;
|
|
792
819
|
/**
|
|
793
820
|
* Create an image field for an image
|
|
@@ -801,14 +828,14 @@ declare class Image extends LabelField {
|
|
|
801
828
|
static create(image: string | Blob, x: number, y: number, width?: number, height?: number): Promise<Image>;
|
|
802
829
|
}
|
|
803
830
|
|
|
804
|
-
declare class QRCode extends
|
|
831
|
+
declare class QRCode extends RotatableLabelField implements PositionedField {
|
|
805
832
|
private readonly content;
|
|
806
|
-
private
|
|
807
|
-
private
|
|
833
|
+
private x;
|
|
834
|
+
private y;
|
|
808
835
|
private readonly width;
|
|
809
|
-
private rotation;
|
|
810
836
|
constructor(content: string, x: number, y: number, width: number);
|
|
811
|
-
|
|
837
|
+
setPosition(position: Point): void;
|
|
838
|
+
getPosition(): Point;
|
|
812
839
|
commandForLanguage(language: PrinterLanguage, config?: PrintConfig | undefined): Promise<Command>;
|
|
813
840
|
}
|
|
814
841
|
|