碳带厂商-李生 发表于 2015-8-7 09:44:17

Power Builder利用ZPL指令操作Zebra 105SL条码打印机

问题:PB中如何利用ZPL指令操作Zebra 105SL 条码打印机?
新人解答:看看下面一段代码对你有没有启发:
//条码打印函数
//asValue         : 需要打印的字符
//asPort : 打印机所在的端口
//abShow : 是否打印条码明文
//返回:
//0 : 打印参数有误
//-1 : 端口打开失败
//-2 : 打印命令发送失败
//-3 : 关闭端口失败
//1 : 成功

//ZPL 条码命令注释
//^XA --开始标志
//^Fo20 --位置:Fox,y
//^BY2,2.9 --宽度1-10,2.0-3.0
//^BCN,N,100,N,N --条码类别,我打的是128
//^FD1234567890123^FS --打印内容
//^XZ --结束标志

int liRet,liHnd
string lsShow = 'N'
string lsPrintCode = '^XA^Fo70,80^BY2,2.9^BCN,100,'

if isnull(asValue) or isnull(asPort) or isnull(abShow) then return 0
if abShow then lsShow = 'Y'
lsPrintCode = lsPrintCode + lsShow + ',N,N,N^FD'
lsPrintCode = lsPrintCode + asValue + '^FS^XZ'

liHnd = FileOpen(asPort,LineMode!, Write!, LockWrite!, Append!)
if liHnd = -1 then return -1
liRet = filewrite(liHnd,lsPrintCode)
if liRet = -1 then
fileclose(liHnd)
return -2
end if
liRet = fileclose(liHnd)
if liRet = -1 then return -3
sleep(0.2)
return 1
页: [1]
查看完整版本: Power Builder利用ZPL指令操作Zebra 105SL条码打印机