From ca3fadde1c8d94cce059d6da410b35de4f55014b Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 28 Feb 2022 13:36:29 +0100 Subject: [PATCH] added 2d barcode --- Controllers/PrinterController.cs | 3 +++ Instructions/Barcode2D.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Instructions/Barcode2D.cs diff --git a/Controllers/PrinterController.cs b/Controllers/PrinterController.cs index e30b85b..f9d0ed7 100644 --- a/Controllers/PrinterController.cs +++ b/Controllers/PrinterController.cs @@ -50,6 +50,9 @@ public class PrinterController : Controller case "feed": parsedInstruction = instruction.Deserialize(); break; + case "barcode2d": + parsedInstruction = instruction.Deserialize(); + break; default: return BadRequest(); } diff --git a/Instructions/Barcode2D.cs b/Instructions/Barcode2D.cs new file mode 100644 index 0000000..33416b4 --- /dev/null +++ b/Instructions/Barcode2D.cs @@ -0,0 +1,27 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using ESCPOS_NET.Emitters; + +public class Barcode2D : BaseInstruction +{ + [DataMember(IsRequired = true)] + public string? data { get; set; } + + [JsonConverter(typeof(JsonStringEnumConverter))] + public TwoDimensionCodeType barcodeType {get; set; } = TwoDimensionCodeType.PDF417; + + [JsonConverter(typeof(JsonStringEnumConverter))] + public Size2DCode size {get; set; } = Size2DCode.NORMAL; + + [JsonConverter(typeof(JsonStringEnumConverter))] + public CorrectionLevel2DCode correctionLevel {get; set; } = CorrectionLevel2DCode.PERCENT_7; + + public override List GetInstructions() + { + var commands = new List(); + + commands.Add(e.Print2DCode(barcodeType,data,size,correctionLevel)); + + return commands; + } +}