标签:intern case 类型 win 微软雅黑 density 类别 download targe
分享 tsc 条码打印机 打印控件 调用方法 , c# silverlight
下载 TSCLIB.dll
http://download.csdn.net/detail/peiyu_peiyu/4789714 或 网上搜索 TSCLIB.dll
复制到 windows\system 文件夹下
c#
public class tcsBasePrint
{
//[DllImport("TSCLib.dll")]
//public static extern int sendcommand(string command);//open connect port
//[DllImport("TSCLib.dll")]
//public static extern int openport(string port);//open connect port
//[DllImport("TSCLib.dll")]
//public static extern int closeport();//close connect port
//[DllImport("TSCLib.dll")]
///*
// width:列印宽度,单位mm
// height:列印长度,单位mm
// speed:列印速度 4.0 代表每秒4英寸速度
// density:列印浓度 0-15 越大表示浓度越高
// sensor:设定感测器类别 0 表示垂直感测器,1 表示黑标感测器
// vertical:设定间距高度
// pchar:设定偏移间距 0 参数一般设为0
// */
//public static extern int setup(string width, string height, string speed, string density, string sensor, string vertical, string pchar);
//[DllImport("TSCLib.dll")]
//public static extern int clearbuffer();//clear buffer
//[DllImport("TSCLib.dll")]
///*
// x:字串型別,條碼X 方向起始點,以點(point)表示。(200 DPI,1 點=1/8 mm, 300 DPI,1 點=1/12 mm)
// y:条码Y方向起始点
// codeType:条码类型(128,39,93等)
// height:代表条码的高度,高度以点来表示
// readable:设定是否列印条码码文
// rotation:设定条码的旋转角度
// narrow:设定条码窄的比例因子
// wide:设定条码宽的比例因子
// code:条码内容
// pchar:设定偏移间距 0 参数一般设为0
// */
///*
// narrow : wide
// 1:1
// narrow : wide
// 1:2
// narrow : wide
// 1:3
// narrow : wide
// 2:5
// narrow : wide
// 3:7
// */
//public static extern int barcode(string x, string y, string codeType, string height, string readable, string rotation, string narrow, string wide, string code, string pchar);
//[DllImport("TSCLib.dll")]
///*
// x:文字X方向起始点
// y:文字Y方向起始点
// fontName:文字类型
// rotation:文字旋转角度
// xmul:设定文字X方向的放大倍率
// ymul:设定文字Y方向的放大倍率
// content:列印文字的内容
// */
//public static extern int printerfont(string x, string y, string fontName, string rotation, string xmul, string ymul, string content);
//[DllImport("TSCLib.dll")]
///*
// x:文字X方向起始点
// y:文字Y方向起始点
// fontHeight:字体高度
// rotation:文字旋转角度
// fontStyle:字体外形
// fontUnderline:底线
// faceName:字体名称
// content:列印内容
// */
//public static extern int windowsfont(int x, int y, int fontHeight, int rotation, int fontStyle, int fontUnderline, string faceName, string content);
//[DllImport("TSCLib.dll")]
///*
//打印设置
// a为式数
// b为份数
//*/
//public static extern int printlabel(string a, string b);
//[DllImport("TSCLib.dll")]
///*
// 设定打印后回卷
// */
//public static extern int formfeed();
//[DllImport("TSCLib.dll")]
///*
// 设定打印不后回卷
//*/
//public static extern int nobackfeed();
[DllImport("TSCLIB.dll")]
public static extern int about();
[DllImport("TSCLIB.dll", EntryPoint = "openport")]
public static extern int openport(string printername);
[DllImport("TSCLIB.dll", EntryPoint = "barcode")]
public static extern int barcode(string x, string y, string type, string height, string readable, string rotation, string narrow, string wide, string code);
[DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
public static extern int clearbuffer();
[DllImport("TSCLIB.dll", EntryPoint = "closeport")]
public static extern int closeport();
[DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
public static extern int downloadpcx(string filename, string image_name);
[DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
public static extern int formfeed();
[DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
public static extern int nobackfeed();
[DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
public static extern int printerfont(string x, string y, string fonttype, string rotation, string xmul, string ymul, string text);
[DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
public static extern int printlabel(string set, string copy);
[DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
public static extern int sendcommand(string printercommand);
[DllImport("TSCLIB.dll", EntryPoint = "setup")]
public static extern int setup(string width, string height, string speed, string density, string sensor, string vertical, string offset);
[DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
public static extern int windowsfont(int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, string szFaceName, string content);
}
调用:
return printobj.tcsBasePrint.about();
printobj.tcsBasePrint.openport(prot); // // prot 打印机名称 从 控制面板 ”设备和打印机“ 拷贝即可
printobj.tcsBasePrint.clearbuffer();
printobj.tcsBasePrint.windowsfont(x, y, 20,"0", 2, 0, "微软雅黑", strt1);//X Y 坐标 strt1 字符串
switch (barcodetype.ToLower())
{
case "128":
case "39":
printobj.tcsBasePrint.barcode(x.ToString(), y.ToString(), barcodetype, "20", "1", "0", "2", "1", strt1);
break;
case "qr":
printobj.tcsBasePrint.sendcommand("QRCODE " + x.ToString() + "," + y.ToString() + ",M,7,A,0,\"" + strt1 + "\"");
break;
case "pdf417":
printobj.tcsBasePrint.sendcommand("PDF417 " + x.ToString() + "," + y.ToString() + ",300,200," + (modelhead.i03.Value + 180).ToString() + ",\"" + strt1 + "\"");
break;
}
// System.Threading.Thread.Sleep(10);
continue;
}
}
printobj.tcsBasePrint.printlabel("1", "1");
printobj.tcsBasePrint.closeport();
标签:intern case 类型 win 微软雅黑 density 类别 download targe
原文地址:http://www.cnblogs.com/wlming/p/6177911.html