1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
use super::commons::{Justification, YesNo};
/// Represents the supported ZPL commands in the AST.
#[derive(Debug, Clone)]
#[allow(dead_code, clippy::enum_variant_names)]
pub enum Command {
/// ^XA - Start Format
/// Starts the definition of a label format.
StartFormat,
/// ^XZ - End Format
/// Terminates the definition of a label format.
EndFormat,
/// ^LH - Label Home
/// Defines the default home position for the label.
LabelHome {
/// X coordinate of the home position (in dots)
x: Option<u32>,
/// Y coordinate of the home position (in dots)
y: Option<u32>,
},
/// ^LL - Label Length
/// Defines the length of the label (Y axis).
LabelLength {
/// Length of the label in dots
length: Option<u32>,
},
/// ^FO - Field Origin
/// Sets the top-left corner of the field area relative to the Label Home.
FieldOrigin {
/// X coordinate (in dots)
x: Option<u32>,
/// Y coordinate (in dots)
y: Option<u32>,
},
/// ^FT - Field Typeset
/// Sets the field position relative to the Label Home, defining the font's base point.
FieldTypeset {
/// X coordinate (in dots)
x: Option<u32>,
/// Y coordinate (in dots)
y: Option<u32>,
},
/// ^FS - Field Separator
/// Indicates the end of a field definition.
FieldSeparator,
/// ^LR - Label Reverse
/// Inverts the printing of the entire label (white on black).
LabelReverse {
/// Reverse label (Y/N)
reverse: Option<YesNo>,
},
/// ^FX - Comment
/// A comment that does not print or affect the label.
Comment {
/// Comment text
text: String,
},
/// ^A - Font Specification (Full)
/// Specifies the font to be used in the following text field.
FontSpecFull {
/// Font name/letter (A-Z, 0-9)
font_name: char,
/// Field orientation (N, R, I, B)
orientation: Option<char>,
/// Character height in dots
height: Option<u32>,
/// Character width in dots
width: Option<u32>,
},
/// ^CF - Change Default Font
/// Sets the default alphanumeric font.
FontSpec {
/// Font name/letter
font_name: char,
/// Character height
height: Option<u32>,
/// Character width
width: Option<u32>,
},
/// ^FD - Field Data
/// Defines the data to be printed in the field.
FieldData {
/// Data string
data: String,
},
/// ^FB - Field Block
/// Formats a block of text within a defined rectangle.
FieldBlock {
/// Width of the text block
width: Option<u32>,
/// Maximum number of lines
max_lines: Option<u32>,
/// Extra space between lines
line_spacing: Option<u32>,
/// Text justification (L, C, R, J)
justification: Option<Justification>,
/// Indentation for the second line onwards
indent: Option<u32>,
},
/// ^CI - Change International Font/Encoding
/// Changes the character set or international encoding.
ChangeIntFont {
/// Character set identifier
charset: Option<u32>,
},
/// ^FR - Field Reverse Print
/// Prints the field as white on black (inverted).
FieldReverse,
/// ^GB - Graphic Box
/// Draws boxes or lines.
GraphicBox {
/// Box width
width: u32,
/// Box height
height: u32,
/// Border thickness
border_thickness: Option<u32>,
/// Line color (B=Black, W=White)
line_color: Option<char>,
/// Corner rounding (0-8)
corner_rounding: Option<u32>,
},
/// ^GC - Graphic Circle
/// Draws a circle.
GraphicCircle {
/// Circle diameter
diameter: Option<u32>,
/// Border thickness
border_thickness: Option<u32>,
/// Line color
line_color: Option<char>,
},
/// ^GE - Graphic Ellipse
/// Draws an ellipse.
GraphicEllipse {
/// Ellipse width
width: Option<u32>,
/// Ellipse height
height: Option<u32>,
/// Border thickness
border_thickness: Option<u32>,
/// Line color
line_color: Option<char>,
},
/// ^GF - Graphic Field
/// Allows downloading graphic data directly to the bitmap buffer.
GraphicField {
/// Compression type (A, B, C)
compression_type: Option<char>,
/// Total binary data byte count
binary_byte_count: Option<u32>,
/// Total graphic field byte count
graphic_field_count: Option<u32>,
/// Bytes per data row
bytes_per_row: Option<u32>,
/// Image data (hexadecimal or binary)
data: String,
},
/// ^GIC - Custom Image Color (Extension)
/// Custom command to load color images with width, height and base64 data.
CustomImage {
/// Image width
width: u32,
/// Image height
height: u32,
/// Base64 encoded image data
data: String,
},
/// ^GTC - Custom Text Color (Extension)
/// Custom command to set the color of subsequent text fields.
GraphicTextColor {
/// Color in hex format (e.g., #FF0000)
color: String,
},
/// ^GLC - Custom Line Color (Extension)
/// Custom command to set the color of subsequent graphic elements.
GraphicLineColor {
/// Color in hex format (e.g., #FF0000)
color: String,
},
/// ^IFC - If Condition Custom
/// Custom command to render the current field only if a variable matches a value.
IfCondition {
/// The variable name
variable: String,
/// The expected value to match
value: String,
},
/// ^BC - Code 128 Barcode
/// Code 128 Barcode (Subsets A, B, and C).
Code128 {
/// Orientation
orientation: Option<char>,
/// Bar height
height: Option<u32>,
/// Print interpretation line (Y/N)
interpretation_line: Option<char>,
/// Interpretation line above (Y/N)
interpretation_line_above: Option<char>,
/// Verify check digit (Y/N)
check_digit: Option<char>,
/// Mode (N=Not selected, U=UCC Case Mode, A=Automatic, D=UCC/EAN Display)
mode: Option<char>,
},
/// ^BQ - QR Code Barcode
/// QR Code Barcode.
QRCode {
/// Orientation
orientation: Option<char>,
/// Model (1=Original, 2=Enhanced)
model: Option<u32>,
/// Magnification factor (1-10)
magnification: Option<u32>,
/// Error correction level (H, Q, M, L)
error_correction: Option<char>,
/// Data mask (0-7)
mask: Option<u32>,
},
/// ^B3 - Code 39 Barcode
/// Code 39 Barcode.
Code39 {
/// Orientation
orientation: Option<char>,
/// Check digit
check_digit: Option<char>,
/// Bar height
height: Option<u32>,
/// Print interpretation line
interpretation_line: Option<char>,
/// Interpretation line above
interpretation_line_above: Option<char>,
},
/// ^BY - Barcode Field Default
/// Changes the default values for barcodes.
BarcodeDefault {
/// Module width (in dots)
module_width: Option<u32>,
/// Wide to narrow bar ratio
ratio: Option<f32>,
/// Bar height
height: Option<u32>,
},
/// ^BX - Data Matrix Barcode
/// Two-dimensional Data Matrix Barcode.
DataMatrix {
/// Orientation
orientation: Option<char>,
/// Dimensional height
height: Option<u32>,
/// Quality level
quality: Option<u32>,
/// Columns to encode
columns: Option<u32>,
/// Rows to encode
rows: Option<u32>,
},
/// ^B7 - PDF417 Barcode
/// Multi-dimensional PDF417 Barcode.
Pdf417 {
/// Orientation
orientation: Option<char>,
/// Bar height
height: Option<u32>,
/// Security level
security_level: Option<u32>,
/// Number of data columns
columns: Option<u32>,
/// Number of rows
rows: Option<u32>,
/// Truncate symbol (Y/N)
truncate: Option<YesNo>,
},
/// Unsupported or unknown command
UnsupportedCommand {
/// Command code (e.g., ^XY)
command: String,
/// Raw command arguments
args: String,
},
}