如何使用带有EPSON命令的热敏打印机打印QR码?

时间:2019-05-13 21:13:12

标签: c# qr-code thermal-printer

我需要使用热敏打印机打印QR码,我试图使用EPSON命令使其正常工作,但没有成功。当我尝试使用此代码打印QR时,我只会得到打印机的信息。有人解决过这样的问题吗?

这是我未使用的代码。

var m_encoding = Encoding.Default;
string QRdata = Purchase.TransactionReference.BookingId;
int store_len = QRdata.Length + 3;
byte store_pL = (byte)(store_len % 256);
byte store_pH = (byte)(store_len / 256);


string txt = m_encoding.GetString(new byte[] { 9 }); //TAB
txt += m_encoding.GetString(new byte[] { 9 }); //TAB
txt += m_encoding.GetString(new byte[] { 9 }); //TAB
txt += m_encoding.GetString(new byte[] { 9 }); //TAB
txt += m_encoding.GetString(new byte[] { 29, 40, 107, store_pL, store_pH, 49, 80, 48 }); //FUNCTION 80
txt += QRdata;
txt += m_encoding.GetString(new byte[] { 29, 40, 107, 3, 0, 49, 69, 48 }); //FUNCTION 69
txt += m_encoding.GetString(new byte[] { 29, 40, 107, 3, 0, 49, 67, 5 }); //FUNCTION 67
txt += m_encoding.GetString(new byte[] { 29, 40, 107, 4, 0, 49, 65, 50, 0 }); //FUNCTION 65
txt += m_encoding.GetString(new byte[] { 29, 40, 107, 3, 0, 49, 81, 48 }); //FUNCTION 81                        
txt += m_encoding.GetString(new byte[] { 13 }); //CR
txt += m_encoding.GetString(new byte[] { 10 }); //LF
txt += m_encoding.GetString(new byte[] { 10 }); //LF
txt += m_encoding.GetString(new byte[] { 10 }); //LF
txt += m_encoding.GetString(new byte[] { 27, 105 }); //CUT
var resultQR = GenerateStreamFromString(txt);
BinaryReader binaryQR = new BinaryReader(resultQR, Encoding.Default);
port.Write(binaryQR.ReadBytes((int)resultQR.Length), 0, (int)resultQR.Length);

0 个答案:

没有答案