我想用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)
uj5u.com熱心網友回復:
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)
uj5u.com熱心網友回復:
SM4是條碼專用列印機,可能不支持漢字列印,建議咨詢一下廠家uj5u.com熱心網友回復:
你的條碼型別不支持漢字uj5u.com熱心網友回復:
絕對支持,我們就在用uj5u.com熱心網友回復:
想發帖,得先頂斬訓分啊uj5u.com熱心網友回復:
想發帖,得先頂斬訓分啊uj5u.com熱心網友回復:
uo_fnthex z4M //斑馬z4M系列機器str_barcode str_bar //列印條碼結構
integer li_filename,li_gx // X軸的位置
string ls_PrtStr,ls_code ,ls_bar,ls_name,a
Long I,row,P,P_count //行數
dw_1.accepttext( )
IF dw_1.rowcount( )=0 Then
messagebox('提示','無資訊列印!',exclamation!)
return
End IF
IF messagebox('詢問','是否列印下列已選中的條碼?',question!,yesno!)=2 Then return
//以下是列印條碼模塊
for row=1 to dw_1.rowcount( )
// p_count=Ceiling( dw_1.getitemnumber( row, "fs") /2)
If dw_1.getitemstring( row, "sel")="1" Then
ls_PrtStr="^XA^IA6^XZ^FS^XA^FS^BY2,2^LH10,13^FS" //定位
li_gx=10
for i=1 to 2
//ls_PrtStr += z4m.uf_PrtChnStr(li_gx, 10, "宋體", 14, 2, 2, "資產:" + dw_1.getitemstring(row,"item") ) //打標頭
//打條碼
//ls_PrtStr += "^FO" + string(li_gx + 20) + "," + string(10+ 35 ) + "^BE,"+string(50)+"^FD" + dw_1.getitemstring(row,"barcode") + "^FS"
IF dw_1.getitemstring( row, "yn_price")="1" and dw_1.getitemnumber( row, "prices")>0 THEN
ls_PrtStr += z4m.uf_PrtChnStr(li_gx, 10, "宋體", 14, 2, 2,"零售價:¥" + string(dw_1.getitemnumber( row, "prices")))
ELSE
ls_PrtStr += z4m.uf_PrtChnStr(li_gx, 10, "宋體", 14, 2, 2,"●" ) //裝訂扣點
END IF
//ls_PrtStr += z4m.uf_PrtChnStr(li_gx, 50, "宋體", 14, 2, 2, "售價:" + dw_1.getitemstring(row,"sp_price") ) //打標頭售價
ls_PrtStr += z4m.uf_PrtChnStr(li_gx, 118, "宋體", 14, 2, 2, "商品:" + dw_1.getitemstring(row,"sp_code") ) //打標頭代碼
ls_PrtStr += z4m.uf_PrtChnStr(li_gx + 10, 148, "宋體", 14, 1, 2, left(dw_1.getitemstring(row,"sp_name"),20) + " <" + dw_1.getitemstring(row,"sp_dw") + ">" )
//ls_PrtStr += z4m.uf_PrtChnStr(li_gx + 10, 148, "宋體", 14, 1, 2, "管理日期:"+string(now(),'yyyy-mm-dd'))
li_gx+=260
Next
ls_PrtStr += "^PQ" + trim(string(Ceiling( dw_1.getitemnumber( row, "sl") /2)))+"^FS"
ls_PrtStr += "^PRC^FS^XZ^FS^XA^EG^XZ" //結束命令
li_filename=FileOpen("PRN",linemode!,write!,lockwrite!,replace!)
if li_filename = -1 then
Messagebox("警告","條碼列印設備打開失敗!",StopSign!)
Return
end if
FileWrite(li_filename,ls_PrtStr)
FileClose(li_filename)
end IF
P=0 //將資產序號統計為零
next
IF messagebox('詢問','是否執行清除?',question!,yesno!)=2 THEN RETURN
dw_1.reset( )
this.event ue_add( )
dw_1.setfocus( )
global type str_barcode from structure
string gs_prt_yn
string gs_market
string gs_price_ttl
string gs_price_h
string gs_font
string gs_printer
string gs_kpday_ttl
string gs_direction
string gs_print_lpt
string gs_bar_13
string gs_kpday_mode
string gs_price_sort[]
string gs_regpath
string gs_sh_market
string gs_sh_title
string gs_sh_unit
integer gi_y
integer gi_xk
integer amou_line
integer gi_i
integer gi_width
integer gi_height
integer gi_sh_hs
integer gi_darkness
long gi_counter_a
long gi_counter
string gs_kpday_check
string gs_price_check
string gs_show_counter
string gs_query
string gs_dw_mode
end type
forward
global type uo_fnthex from nonvisualobject
end type
end forward
global type uo_fnthex from nonvisualobject
end type
global uo_fnthex uo_fnthex
type prototypes
//S500斑馬列印機
FUNCTION long GETFONTHEX ( string outStr, &
string lfFaceName, &
/*列印方向*/ int lfOrientation, &
/*列印高度*/ int lfHeight, &
/*列印寬度*/ int lfWidth, &
/*列印粗體*/ int lfBold, &
/*列印斜體*/ int lfItalic, &
/*緩沖區*/ ref string hexBuf &
) LIBRARY "Fnthex32.DLL"
end prototypes
forward prototypes
public function string uf_prtchnstr (integer ai_x, integer ai_y, string as_fontname, integer ai_height, integer ai_xmf, integer ai_ymf, string as_chnstr)
end prototypes
public function string uf_prtchnstr (integer ai_x, integer ai_y, string as_fontname, integer ai_height, integer ai_xmf, integer ai_ymf, string as_chnstr);string ls_Buf, ls_return
long ll_Count
ls_Buf = SPACE(21 * 1024) // 分配存盤16進制資料空間
ll_Count = GetFontHex ( as_chnstr, as_fontname, 0 , ai_height, 0, 1, 0, ls_buf)
IF ll_Count <= 0 then RETURN ""
// 將漢字調入列印機
ls_return = mid(ls_Buf,1,ll_Count)
//斑馬列印機
// cBuf = STUFF(cBuf, 4, 8, "CHNSTR01")
// 列印字串: ^FO<nX>,<nY>^XG<NAME>,nXMF,nYMF^FS
//^FO<nX>,<nY>指定一個列印范圍,引數X軸和Y軸。EG:^FOxy
//^XG<NAME>:呼叫要列印的圖形, NAME是定義的圖形檔案名 OUTSTR01
//FS分隔符
ls_return = ls_return + '^FO' + TRIM(string(ai_X)) + ',' + TRIM(string(ai_Y)) + &
'^XGOUTSTR01,' + trim(string(ai_XMF)) + ',' + TRIM(string(ai_YMF)) + '^FS'
//ls_return = ls_return + '^FO' + TRIM(string(ai_X + 260)) + ',' + TRIM(string(ai_Y)) + &
// '^XGOUTSTR01,' + trim(string(ai_XMF)) + ',' + TRIM(string(ai_YMF)) + '^FS'
RETURN ls_return
end function
on uo_fnthex.create
call super::create
TriggerEvent( this, "constructor" )
end on
on uo_fnthex.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
uj5u.com熱心網友回復:
頂頂頂頂頂頂頂頂頂頂轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/89253.html
標籤:數據庫相關
上一篇:資料庫 PB 的視頻資料
下一篇:PB中可以使用.NET 組件嗎?
