1.如果打印机版本是低于A2.16.011 ,使用的是旧版本的DLL,

版本下载:软件开发工具包 (SDK) 下面的Windows DLL (737.23kb)查看里面是不是有你的型号打印机,
2.把下载好的dll 放入到项目的BIN下面,然后进行代码配置就行
3.打印机模板设定,要自己问下打印机供应商,请他们协助(https://www.chinatsc.cn/)
public class TSCLIB_DLL
{
[DllImport("TSCLIB.dll", EntryPoint = "about")]
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);
[DllImport("TSCLIB.dll", EntryPoint = "windowsfontUnicode")]
public static extern int windowsfontUnicode(int x, int y, int fontheight,
int rotation, int fontstyle, int fontunderline,
string szFaceName, byte[] content);
}
}
public void PrintByTSC(List<WaOGQrData> par)
{
TSCLIB_DLL.openport(printName);
TSCLIB_DLL.sendcommand("SIZE 100 mm,60 mm");//实际纸张的大小
TSCLIB_DLL.sendcommand("GAP 3 mm,0 mm");//注意:如果你的打印多张出现了错位,那说明两张纸的间隙出问题,用尺量下就好
TSCLIB_DLL.sendcommand("DENSITY 8");
TSCLIB_DLL.sendcommand("SPEED 3");
TSCLIB_DLL.sendcommand("DIRECTION 1,0");
TSCLIB_DLL.sendcommand("REFERENCE 0,0");
TSCLIB_DLL.sendcommand("CLS");
TSCLIB_DLL.sendcommand("BOX 35,10,1150,680,4");
TSCLIB_DLL.sendcommand("PUTBMP 850,20,\"LOGOCP.BMP\"");//这里的图片是放在打印机里面,需要使用tsc家自己工具
TSCLIB_DLL.windowsfontUnicode(100, 60, 60, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("FFU AMC Filter-堆疊式四層濾網"));
TSCLIB_DLL.windowsfontUnicode(100, 180, 60, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("TSMC PN:"));
TSCLIB_DLL.sendcommand("BARCODE 370,150,\"128\",80,2,0,4,3,\"111111\"");
TSCLIB_DLL.windowsfontUnicode(100, 280, 50, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("Spec:3F103465+3F103466+3F103467+3F103467"));
TSCLIB_DLL.windowsfontUnicode(100, 360, 60, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("Maker:鈺祥企業"));
TSCLIB_DLL.windowsfontUnicode(100, 470, 60, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("條碼:" ));
TSCLIB_DLL.sendcommand("QRCODE 250,440,H,7,A,0,\"" + waQrData.A3 + "\"");
TSCLIB_DLL.windowsfontUnicode(210, 620, 50, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes(waQrData.A3));
TSCLIB_DLL.windowsfontUnicode(600, 490, 60, 0, 2, 0, "微軟正黑體", System.Text.Encoding.Unicode.GetBytes("Q'ty:" + waQrData.A4));
TSCLIB_DLL.printlabel("1", "1");
TSCLIB_DLL.closeport();
}
877

被折叠的 条评论
为什么被折叠?



