diff --git a/printer_zpl2/models/printing_label_zpl2.py b/printer_zpl2/models/printing_label_zpl2.py
index 9552d8d..e8bf697 100644
--- a/printer_zpl2/models/printing_label_zpl2.py
+++ b/printer_zpl2/models/printing_label_zpl2.py
@@ -123,6 +123,16 @@ class PrintingLabelZpl2(models.Model):
zpl2.ARG_COLOR: component.color,
zpl2.ARG_ROUNDING: component.rounding,
})
+ elif component.component_type == 'diagonal':
+ label_data.graphic_diagonal_line(
+ component_offset_x, component_offset_y, {
+ zpl2.ARG_WIDTH: component.width,
+ zpl2.ARG_HEIGHT: component.height,
+ zpl2.ARG_THICKNESS: component.thickness,
+ zpl2.ARG_COLOR: component.color,
+ zpl2.ARG_DIAGONAL_ORIENTATION:
+ component.diagonal_orientation,
+ })
elif component.component_type == 'graphic':
image = component.graphic_image or data
pil_image = Image.open(io.BytesIO(
diff --git a/printer_zpl2/models/printing_label_zpl2_component.py b/printer_zpl2/models/printing_label_zpl2_component.py
index 903169e..efdd593 100644
--- a/printer_zpl2/models/printing_label_zpl2_component.py
+++ b/printer_zpl2/models/printing_label_zpl2_component.py
@@ -42,6 +42,7 @@ class PrintingLabelZpl2Component(models.Model):
selection=[
('text', 'Text'),
('rectangle', 'Rectangle / Line'),
+ ('diagonal', 'Diagonal Line'),
('circle', 'Circle'),
('graphic', 'Graphic'),
(zpl2.BARCODE_CODE_11, 'Code 11'),
@@ -85,6 +86,12 @@ class PrintingLabelZpl2Component(models.Model):
(zpl2.ORIENTATION_BOTTOM_UP, 'Read from Bottom up'),
], required=True, default=zpl2.ORIENTATION_NORMAL,
help='Orientation of the barcode.')
+ diagonal_orientation = fields.Selection(
+ selection=[
+ (zpl2.DIAGONAL_ORIENTATION_LEFT, 'Left (\\)'),
+ (zpl2.DIAGONAL_ORIENTATION_RIGHT, 'Right (/)'),
+ ], default=zpl2.DIAGONAL_ORIENTATION_LEFT,
+ help='Orientation of the diagonal line.')
check_digits = fields.Boolean(
help='Check if you want to compute and print the check digit.')
height = fields.Integer(
diff --git a/printer_zpl2/tests/test_printing_label_zpl2.py b/printer_zpl2/tests/test_printing_label_zpl2.py
index ec610fe..7418382 100644
--- a/printer_zpl2/tests/test_printing_label_zpl2.py
+++ b/printer_zpl2/tests/test_printing_label_zpl2.py
@@ -527,6 +527,35 @@ class TestPrintingLabelZpl2(TransactionCase):
# Label end
'^XZ')
+ def test_diagonal_line_label_contents(self):
+ """ Check contents of a diagonal line label """
+ label = self.new_label()
+ self.new_component({
+ 'label_id': label.id,
+ 'component_type': 'diagonal',
+ })
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
+ self.assertEqual(
+ contents,
+ # Label start
+ '^XA\n'
+ # Print width
+ '^PW480\n'
+ # UTF-8 encoding
+ '^CI28\n'
+ # Label position
+ '^LH10,10\n'
+ # Component position
+ '^FO10,10'
+ # Component format
+ '^GD3,3,1,B,L'
+ # Component end
+ '^FS\n'
+ # Recall last saved parameters
+ '^JUR\n'
+ # Label end
+ '^XZ')
+
def test_circle_label_contents(self):
""" Check contents of a circle label """
label = self.new_label()
diff --git a/printer_zpl2/views/printing_label_zpl2.xml b/printer_zpl2/views/printing_label_zpl2.xml
index fd7d04c..9dd679e 100644
--- a/printer_zpl2/views/printing_label_zpl2.xml
+++ b/printer_zpl2/views/printing_label_zpl2.xml
@@ -64,24 +64,25 @@
-
+
-
+
-
+
-
-
+
+
+
-
+