protected void Button1_Click(object sender, EventArgs e) { //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true); //TSCLIB_DLL.about(); //Show the DLL version TSCLIB_DLL.openport("TSC TTP-243 Plus"); //Open specified printer driver TSCLIB_DLL.setup("52", "28.5", "4", "5", "0", "0", "0"); /* * width 設定標籤寬度 單位mm * height 設定標籤高度 單位mm * speed 設定列印速度 單位sec 間距1~10 * density 設定列印濃度 單位 間距0~15 * sensor 設定使用感應器類別 0 表示使用垂直間距感測器(gap sensor) 1 表示使用黑標感測器(black mark sensor) * vertical 字串型別,設定gap/black mark 垂直間距高度,單位:mm * offset 字串型別,設定gap/black mark 偏移距離,單位: mm,此參數若使用一般標籤時設為0 */ TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.barcode("80", "60", "128", "90", "1", "0", "4", "4", "3680302001393"); /* * x 字串型別,條碼X方向起始點,以點(point)表示。 * y 字串型別,條碼Y方向起始點,以點(point)表示。 * type 字串型別 * height 字串型別,設定條碼高度,高度以點來表示。 * readable 字串型別,設定是否列印條碼碼文 0: 不列印碼文 1: 列印碼文 * rotation 字串型別,設定條碼旋轉角度 * narrow 字串型別,設定條碼窄bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度) * wide 字串型別,設定條碼寬bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度) * code 要列印的條碼 */ TSCLIB_DLL.printerfont("100", "200", "4", "0", "1", "2", "Bg04-11"); /* * x: 字串型別,文字X方向起始點,以點(point)表示。 * y: 字串型別,文字Y方向起始點,以點(point)表示。 * fonttype: 字串型別,內建字型名稱,共12種。1~5 * rotaiton: 字串型別,設定文字旋轉角度 * xmul: 字串型別,設定文字X方向放大倍率,1~8 * ymul: 字串型別,設定文字y方向放大倍率,1~8 * text: 字串型別,列印文字內容 * */ TSCLIB_DLL.windowsfont(50, 270, 30, 0, 0, 0, "標楷體", "MPU-6050三軸加速度傳感器-送排針"); /* * x: 整數型別,文字X方向起始點,以點(point)表示。 * y: 整數型別,文字y方向起始點,以點(point)表示。 * fonthigrt:整數型別,字體高度,以點(point)表示。 * rotation :整數型別,旋轉角度,逆時鐘方向旋轉 * fontstyle:整數型別,字體外形 0-> 標準(Normal)1-> 斜體(Italic)2-> 粗體(Bold)3-> 粗斜體(Bold and Italic) * fontline :整數型別,底線0-> 無底線1-> 加底線 * szface :字串型別,字體名稱。如: Arial, Times new Roman, 細名體, 標楷體 * content :字串型別,列印文字內容。 */ //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX"); //Download PCX file into printer //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer //TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\""); //Drawing PCX graphic TSCLIB_DLL.printlabel("1", "1"); //set: 字串型別,設定列印標籤式數(set)copy: 字串型別,設定列印標籤份數(copy) 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 }
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(); }
public void Print(ExportDetail itm) { if (Export.SourceTransaction != "Sales Order") { return; } try { for (int i = 0; i < Quantity; i++) { const int VerticalSpace = 150; const int HorizontalSpace = 100; const string LabelFontSize = "2.5"; TSCLIB_DLL.openport(Settings.Default.TSCPrinter); //Open specified printer driver TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx"); //Download PCX file into printer TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B."); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada"); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Instance.Info.Substring(0, Instance.Info.IndexOf(" - "))); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Instance.Info.Substring(Instance.Info.IndexOf(" - ") + 1)); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd")); //Drawing printer font TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", itm.Weight.ToString()); TSCLIB_DLL.printerfont((HorizontalSpace * 1.5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", "LBS."); TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { //TSCLIB_DLL.about(); //Show the DLL version TSCLIB_DLL.openport("TSC TTP-344M Plus"); //Open specified printer driver TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test"); //Drawing printer font TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test"); //Draw windows font TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\""); //Drawing PCX graphic TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); //Close specified printer driver }
private void PrintMediumSizeLabel(PurchaseOrderDetail itm) { try { const int VerticalSpace = 75; const int HorizontalSpace = 101; const string LabelFontSize = "2.5"; TSCLIB_DLL.openport(Settings.Default.TSCPrinter); //Open specified printer driver TSCLIB_DLL.setup("101", "50.2", "6", "8", "0", "0", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx"); //Download PCX file into printer TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.Vendor); TSCLIB_DLL.printerfont((HorizontalSpace * 5).ToString(), (VerticalSpace * 1.3).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.PODate.ToString("yyyy-MMM-dd")); //Drawing printer font TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Inv#"); TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.PurchaseOrderNo); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Item:"); TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.ItemDescription); TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "128", "75", "0", "0", "9", "8", itm.Barcode); //Drawing barcode TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 4.1).ToString(), "2", "0", "5", "5", itm.Barcode); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 0, VerticalSpace * 4.5, HorizontalSpace * 2, VerticalSpace * 4.5 + 50)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 5.5, HorizontalSpace * 8, VerticalSpace * 5.5 + 50)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 6.5, HorizontalSpace * 8, VerticalSpace * 6.5 + 50)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 7.5, HorizontalSpace * 8, VerticalSpace * 7.5 + 49)); TSCLIB_DLL.printlabel("1", itm.LabelQty.ToString()); //Print labels TSCLIB_DLL.closeport(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btn_test_Click(object sender, EventArgs e)//测试按钮 { //TSCLIB_DLL.about(); //Show the DLL version TSCLIB_DLL.openport("TSC TDP-245"); //Open specified printer driver TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.about(); TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode TSCLIB_DLL.printerfont("100", "250", "TSS24.BF2", "0", "1", "1", "Print Font 测试"); //Drawing printer font // TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "GBK", "测试"); //Draw windows font // TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer TSCLIB_DLL.sendcommand("PUTPCXL.PC 100,400,\"UL.PCX\""); //Drawing PCX graphic TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); //Close specified printer driver }
protected void Button1_Click(object sender, EventArgs e) { //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true); //TSCLIB_DLL.about(); //Show the DLL version TSCLIB_DLL.openport("TSC TTP-245C"); //Open specified printer driver TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test"); //Drawing printer font TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test"); //Draw windows font //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX"); //Download PCX file into printer TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\""); //Drawing PCX graphic TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); }
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(); } }
public void Print(ExportDetail itm) { if (Export.SourceTransaction != "Sales Order") { return; } try { const int VerticalSpace = 150; const int HorizontalSpace = 100; const string LabelFontSize = "2.5"; TSCLIB_DLL.openport(Settings.Default.TSCPrinter); //Open specified printer driver TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0"); //Setup the media size and sensor type info TSCLIB_DLL.clearbuffer(); //Clear image buffer TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx"); //Download PCX file into printer TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B."); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada"); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Customer.CustomerName); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Customer.CustomerAddress); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd")); //Drawing printer font TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription); TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description); TSCLIB_DLL.printerfont((HorizontalSpace * 3).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", itm.Weight.ToString()); TSCLIB_DLL.printerfont((HorizontalSpace * 4).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", "LBS."); TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode // TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 8.5).ToString(), "3", "0", "2", "2", Box.Description); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4,VerticalSpace * 4,HorizontalSpace * 8,VerticalSpace * 4 + 100)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 5, HorizontalSpace * 8, VerticalSpace * 5 + 100)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 6, HorizontalSpace * 8, VerticalSpace * 6 + 100)); //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#"); //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 7, HorizontalSpace * 8, VerticalSpace * 7 + 100)); TSCLIB_DLL.printlabel("1", "1"); //Print labels TSCLIB_DLL.closeport(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }