printer-api/Instructions/PrintInstruction.cs

30 lines
597 B
C#
Raw Normal View History

2022-02-17 15:45:42 +00:00
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using ESCPOS_NET.Emitters;
using ESCPOS_NET.Utilities;
public class PrintInstruction : BaseInstruction
{
[DataMember(IsRequired = true)]
public string? text { get; set; }
public bool newLine { get; set; } = true;
public override List<byte[]> GetInstructions()
{
var e = new EPSON();
var commands = new List<byte[]>();
if (newLine)
{
commands.Add(e.PrintLine(text));
}
else
{
commands.Add(e.Print(text));
}
return commands;
}
}