private void BtnPrnSticker_Click(object sender, EventArgs e) { //throw new NotImplementedException(); string WT1 = txtName.Text.Trim(); string B1 = txtBarcode.Text.Trim(); byte[] result_unicode = System.Text.Encoding.GetEncoding("utf-16").GetBytes("unicode test"); byte[] result_utf8 = System.Text.Encoding.UTF8.GetBytes("TEXT 40,620,\"ARIAL.TTF\",0,12,12,\"utf8 test Wörter auf Deutsch\""); //TSCLIB_DLL.about(); byte status = TSCLIB_DLL.usbportqueryprinter(); //0 = idle, 1 = head open, 16 = pause, following <ESC>!? command of TSPL manual TSCLIB_DLL.openport("TSC TE210"); TSCLIB_DLL.sendcommand("SIZE 100 mm, 120 mm"); TSCLIB_DLL.sendcommand("SPEED 4"); TSCLIB_DLL.sendcommand("DENSITY 12"); TSCLIB_DLL.sendcommand("DIRECTION 1"); TSCLIB_DLL.sendcommand("SET TEAR ON"); TSCLIB_DLL.sendcommand("CODEPAGE UTF-8"); TSCLIB_DLL.clearbuffer(); //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); TSCLIB_DLL.windowsfont(40, 490, 48, 0, 0, 0, "Arial", "Windows Font Test"); TSCLIB_DLL.windowsfontUnicode(40, 550, 48, 0, 0, 0, "Arial", result_unicode); //TSCLIB_DLL.sendcommand("PUTPCX 40,40,\"UL.PCX\""); TSCLIB_DLL.sendBinaryData(result_utf8, result_utf8.Length); TSCLIB_DLL.barcode("40", "300", "128", "80", "1", "0", "2", "2", B1); TSCLIB_DLL.printerfont("40", "250", "0", "0", "15", "15", WT1); TSCLIB_DLL.printlabel("1", "1"); TSCLIB_DLL.closeport(); }
// Function to perform printing module! private void PrintDemoLabel(bool reprint) { // Read from DB to get counter. return 1 if db not found. // append the string with time,gate and counter // write time, gate, count and reprint to DB. // Print out ticket accordingly. // Update the label for counter. // if reprtint, do not increment the counter. String printformat = UpdateDB(reprint); // Update the counter at here LABEL_COUNT.Invoke(new EventHandler(delegate { LABEL_COUNT.Text = printformat.Split('/').Last(); })); String gatePrint = "Gate: " + printformat.Split('/')[1]; String CountPrint = "Counter: " + printformat.Split('/').Last(); TSCLIB_DLL.openport("TSC TDP-225"); //Open specified printer driver TSCLIB_DLL.setup("40", "450", "12", "8", "1", "6", "300"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.barcode("100", "470", "128", "100", "0", "270", "2", "2", printformat); //Drawing barcode TSCLIB_DLL.printerfont("140", "480", "5", "90", "1", "1", gatePrint); //Print Gate number TSCLIB_DLL.printerfont("210", "480", "5", "90", "1", "1", CountPrint); //Print Ticket Counter TSCLIB_DLL.sendcommand($"QRCODE 80,0,M,7,M,0,M2,S1,\"A{printformat}\""); //Draw QR Code TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); //Close specified printer driver }
public void PrintOverTSC(string model, List <LabelData> labelList) { if (labelList.Count == 0) { return; } try { TSCLIB_DLL.openport(model); foreach (LabelData l in labelList) { TSCLIB_DLL.setup("75", "30", "4", "8", "0", "2", "0"); TSCLIB_DLL.clearbuffer(); TSCLIB_DLL.printerfont("24", "24", "4", "0", "1", "1", l.Device); TSCLIB_DLL.windowsfont(24, 60, 32, 0, 0, 0, "Arial", l.Drawer); TSCLIB_DLL.windowsfont(336, 24, 32, 0, 0, 0, "Arial", currentTime); if (l.MedName.Length <= 43) { TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName); } else { TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName.Substring(0, 43)); TSCLIB_DLL.windowsfont(16, 128, 32, 0, 0, 0, "Arial", l.MedName.Substring(43)); } TSCLIB_DLL.windowsfont(24, 182, 48, 0, 0, 0, "標楷體", $"數量: {l.Amount}"); TSCLIB_DLL.barcode("264", "166", "128", "56", "1", "0", "2", "1", l.MedID); TSCLIB_DLL.printlabel("1", "1"); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { TSCLIB_DLL.closeport(); } }