CodePudding user response:
Find a ZPL specifications, according to the syntax of the above write ZPL commands, and then sent to the printerCodePudding user response:
You're lucky, I just made a//barcode printing function
//asValue: need to print characters
//asPort: printer's port
//abShow: whether to print bar code expressly
//return:
//0: printing parameter wrong
//- 1: port open failure
//- 2: print command failed
//- 3: failed to close port
//1: success
//ZPL barcode command comments
//^ XA - began to sign
//^ Fo20 - location: Fox, y
//^ BY2, 1-2.9 - width 10,2.0-3.0
//^ BCN, N., 100, N, N - barcode category, I'm calling from a 128
//^ FD1234567890123 ^ FS - print content
//^ XZ - end mark
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! The Write! , LockWrite! , Append!)
If liHnd=1 then return 1
LiRet=filewrite (liHnd lsPrintCode)
If liRet=1 then
Fileclose (liHnd)
The return - 2
End the if
LiRet=fileclose (liHnd)
If liRet=1 then return - 3
Sleep (0.2)
Return 1