@node-projects/web-component-designer-zpl 0.1.15 → 0.1.17

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.
@@ -1,6 +1,7 @@
1
1
  import { ITextWriter, IDesignItem, IHtmlParserService, IHtmlWriterOptions, IHtmlWriterService, InstanceServiceContainer, ServiceContainer } from "@node-projects/web-component-designer";
2
2
  export declare class ZplParserService implements IHtmlParserService, IHtmlWriterService {
3
3
  options: IHtmlWriterOptions;
4
+ createTransform(char: string, el: HTMLElement): void;
4
5
  parse(html: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, parseSnippet: boolean): Promise<IDesignItem[]>;
5
6
  write(textWriter: ITextWriter, designItems: IDesignItem[], rootContainerKeepInline: boolean, updatePositions?: boolean): void;
6
7
  }
@@ -13,6 +13,30 @@ function getSetValue(...args) {
13
13
  }
14
14
  export class ZplParserService {
15
15
  options = {};
16
+ createTransform(char, el) {
17
+ switch (char) {
18
+ case 'R':
19
+ {
20
+ el.style.transform = 'rotate(90deg) translateY(-100%)';
21
+ el.style.transformOrigin = '0% 0%';
22
+ return;
23
+ }
24
+ ;
25
+ case 'I': {
26
+ el.style.transform = 'rotate(180deg)';
27
+ el.style.transformOrigin = '50% 50%';
28
+ return;
29
+ }
30
+ case 'B':
31
+ {
32
+ el.style.transform = 'rotate(270deg)';
33
+ el.style.transformOrigin = '100% 100%';
34
+ return;
35
+ }
36
+ ;
37
+ }
38
+ return;
39
+ }
16
40
  async parse(html, serviceContainer, instanceServiceContainer, parseSnippet) {
17
41
  let parts = html.split("^");
18
42
  let images = {};
@@ -34,6 +58,7 @@ export class ZplParserService {
34
58
  let fontName;
35
59
  let fontHeight;
36
60
  let fontWidth;
61
+ let rotation = 'N';
37
62
  let x;
38
63
  let y;
39
64
  let bc;
@@ -62,18 +87,35 @@ export class ZplParserService {
62
87
  comment.setAttribute("content", fieldString);
63
88
  designItems.push(DesignItem.createDesignItemFromInstance(comment, serviceContainer, instanceServiceContainer));
64
89
  break;
65
- case "CF":
90
+ case "AA": //Ax x=fontname
91
+ case "A0": {
92
+ fontName = command[1];
93
+ rotation = getSetValue(fields[0], 'N');
94
+ let defaultFontWidth = 15;
95
+ switch (fontName) {
96
+ case "A":
97
+ defaultFontWidth = 15;
98
+ break;
99
+ case "0":
100
+ defaultFontWidth = fontHeight;
101
+ }
102
+ fontHeight = parseInt(getSetValue(fields[1], defaultFontWidth));
103
+ fontWidth = parseInt(getSetValue(fields[2], defaultFontWidth));
104
+ break;
105
+ }
106
+ case "CF": //we should switch to use A, CF is default font
107
+ rotation = 'N';
66
108
  fontName = fields[0];
67
109
  fontHeight = parseInt(fields[1]);
68
- let defultFontWidth = 15;
110
+ let defaultFontWidth = 15;
69
111
  switch (fontName) {
70
112
  case "A":
71
- defultFontWidth = 15;
113
+ defaultFontWidth = 15;
72
114
  break;
73
115
  case "0":
74
- defultFontWidth = fontHeight;
116
+ defaultFontWidth = fontHeight;
75
117
  }
76
- fontWidth = parseInt(getSetValue(fields[2], defultFontWidth));
118
+ fontWidth = parseInt(getSetValue(fields[2], defaultFontWidth));
77
119
  break;
78
120
  case "FO":
79
121
  x = parseInt(fields[0]);
@@ -168,6 +210,9 @@ export class ZplParserService {
168
210
  text.setAttribute("font-height", fontHeight.toString());
169
211
  text.setAttribute("font-width", fontWidth.toString());
170
212
  text.setAttribute("content", fieldString);
213
+ if (rotation) {
214
+ this.createTransform(rotation, text);
215
+ }
171
216
  designItems.push(DesignItem.createDesignItemFromInstance(text, serviceContainer, instanceServiceContainer));
172
217
  }
173
218
  break;
@@ -85,7 +85,10 @@ export class ZplBarcode extends BaseCustomWebComponentConstructorAppend {
85
85
  zpl += "^BQN,2," + this.height + "";
86
86
  break;
87
87
  }
88
- zpl += "^FD" + this.content;
88
+ zpl += "^FD";
89
+ if (this.type == BarcodeFormat.QR)
90
+ zpl += 'QA,'; // bar code configuration prefix
91
+ zpl += this.content;
89
92
  zpl += "^FS";
90
93
  return zpl;
91
94
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Widgets and Services for creating a ZPL Designer",
3
3
  "name": "@node-projects/web-component-designer-zpl",
4
- "version": "0.1.15",
4
+ "version": "0.1.17",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",