我想用pb做个打印程序, 打印机是斑马S4M;
因为S4M打印不了汉字,其它都正常。
我弄了一天,打印出来的却是空白!!!
还请有做过的帮帮忙!我这程序该怎么写??
怎么才能打出汉字!
代码如下:
function int GETFONTHEX(string outstr,string fontname,&
long orient,long height,long width,long bold,long italic,&
ref string hexbuf) library "fnthex32.dll"
string sString,sPrint
Integer li
String ls_hex
ls_hex = space(21 * 100)
li = GETFONTHEX("汉字",'宋体',1,20,30,1,1,ls_hex) //转换为HEX编码
mle_show.text=ls_hex //将HEX编码显示到mle_show控件
//////////////////////////////////////////////////
long job
job=printopen()
mle_show.print( job,0,0) //打印
printclose(job)
------解决方案--------------------
你这个办法肯定不行,因为你通过WINDOWS驱动方式打印,打的又是一个ls_hex字符串,那肯定打印出来的不会是汉字,而是这个字符串本身,建议你去查看这个打印机的开发文档,一般条码打印机不会不能支持汉字的,是不是该换个驱动
------解决方案--------------------
ls_Buf = SPACE(21 * 1024) // 分配存储16进制数据空间
ll_Count = GetFontHex ( ls_ah, '宋体', 0 , 35, 0, 1, 0, ls_buf) //需要 Fnthex32.DLL
IF ll_Count <= 0 then ls_ah = ""
ls_ah = mid(ls_Buf,1,ll_Count)
ls_ah = ls_ah + '^FO5,150^XGOUTSTR01, 1,1^FS' //x,y
ls_1 = "^XA~r~n" +&
"^LH90,15^BY2.4,2.5,180~r~n" +&
"^FO3,0^BCN,110,N,N,N^FD" + taom + "^FS~r~n" +&
"^FO1,115^ADN,30,15^FD" + taom + "^FS~r~n" + &
ls_ah + "^XZ"
/*
tmprinter =\\计算机名\共享打印机名
本级不用配置fymis.ini
*/
ls_port = profilestring(g_ini_file,"print",'tmprinter',"LPT1")
li_filename=FileOpen(ls_port,linemode!,write!,lockwrite!,replace!)
if li_filename = -1 then
Messagebox("警告","条码打印设备打开失败!",StopSign!)
end if
FileWrite(li_filename,ls_1)
FileClose(li_filename)
------解决方案--------------------
ls_hex = space(21 * 100)
li = GETFONTHEX("汉字",'宋体',1,20,30,1,1,ls_hex) //转换为HEX编码
string ls_print
ls_print = "^XA^IA6^XZ^FS^XA^FS^BY3,3^LH20,23^FS"
ls_print += "^FO30,25^B8,70^FD6905460000130^FS"
ls_print += mid(ls_hex,1,li)
ls_print =ls_print + '^FO10,140^XGOUTSTR01,1,2^FS'
ls_print += "^PQ1^FS"
ls_print += "^PRC^FS^XZ^FS^XA^EG^XZ"
int li_filhle
li_filhle=FileOpen("LPT1"/*打印端口*/,linemode!,write!,lockwrite!,replace!)
if li_filhle= -1 then
Messagebox("警告","条码打印设备打开失败!",StopSign!)
Return
end if
FileWrite(li_filhle,ls_PrtStr)
FileClose(li_filhle)
------解决方案--------------------
SM4是条码专用打印机,可能不支持汉字打印,建议咨询一下厂家
------解决方案--------------------