printer-api/Instructions/TextInstruction.cs

32 lines
663 B
C#
Raw Normal View History

2022-02-17 15:45:42 +00:00
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using ESCPOS_NET.Emitters;
2022-02-17 17:29:32 +00:00
public class TextInstruction : BaseInstruction
2022-02-17 15:45:42 +00:00
{
[DataMember(IsRequired = true)]
public string? text { get; set; }
2022-02-17 17:29:32 +00:00
[JsonConverter(typeof(JsonStringEnumConverter))]
public Alignment alignment {get; set; } = Alignment.Left;
2022-02-17 15:45:42 +00:00
public bool newLine { get; set; } = true;
public override List<byte[]> GetInstructions()
{
var e = new EPSON();
var commands = new List<byte[]>();
2022-02-17 17:29:32 +00:00
commands.Add(alignmentCommand(alignment));
2022-02-17 15:45:42 +00:00
if (newLine)
{
commands.Add(e.PrintLine(text));
}
else
{
commands.Add(e.Print(text));
}
return commands;
}
}