注册 登录
编程论坛 PowerBuilder

求助pb自定义打印纸张。。。

app_boy 发布于 2007-09-17 12:09, 3249 次点击
我的打印机是EPSON TM-U210D Receipt ,在打印时如果数据少的话(如两行),只用把有数据地方打印出来即可,可每次都是有很长的空白内容。请问怎样才能设置一个自定义的高度,我只打印有数据的高度?急
8 回复
#2
app_boy2007-09-17 12:16
#3
app_boy2007-09-17 14:01

怎么没有人恢复阿,难道大家都不用pb了吗?

#4
app_boy2007-09-18 11:34
#5
zxw1035567102007-10-07 08:24
environment env
integer rtn
rtn = GetEnvironment(env)
IF rtn <> 1 THEN return false
if env.OSType=Windows! then //win98!
return SetPaperSize(ai_Width,ai_Height,ai_Orient)=1
else
if env.OSType=WindowsNT! then
string printerName
string paperName
boolean rt
papername=string(ai_width)+"*" +string(ai_height)
printerName = space(255)
rt = GetDefaultPrinter(ref printerName, 255)
if rt then
//messagebox("",trim(printerName))
printername= trim(printerName)
else
return false
end if
DeleteCustomPaper(ref printerName, ref paperName) //先删除纸张
rt = AddCustomPaper(ref printerName, ref PaperName, ai_width, ai_height, 0, 0, 0, 0)
if rt=false then return rt
rt = SetDefaultpaper(ref printerName, ref paperName, ai_orient)
return rt
end if
end if
#6
zxw1035567102007-10-07 08:24
environment env
integer rtn
rtn = GetEnvironment(env)
IF rtn <> 1 THEN return false
if env.OSType=Windows! then //win98!
return SetPaperSize(ai_Width,ai_Height,ai_Orient)=1
else
if env.OSType=WindowsNT! then
string printerName
string paperName
boolean rt
papername=string(ai_width)+"*" +string(ai_height)
printerName = space(255)
rt = GetDefaultPrinter(ref printerName, 255)
if rt then
//messagebox("",trim(printerName))
printername= trim(printerName)
else
return false
end if
DeleteCustomPaper(ref printerName, ref paperName) //先删除纸张
rt = AddCustomPaper(ref printerName, ref PaperName, ai_width, ai_height, 0, 0, 0, 0)
if rt=false then return rt
rt = SetDefaultpaper(ref printerName, ref paperName, ai_orient)
return rt
end if
end if
#7
zxw1035567102007-10-07 08:25

定义下面自定义函数,然后在程序中调用。
environment env
integer rtn
rtn = GetEnvironment(env)
IF rtn <> 1 THEN return false
if env.OSType=Windows! then //win98!
return SetPaperSize(ai_Width,ai_Height,ai_Orient)=1
else
if env.OSType=WindowsNT! then
string printerName
string paperName
boolean rt
papername=string(ai_width)+"*" +string(ai_height)
printerName = space(255)
rt = GetDefaultPrinter(ref printerName, 255)
if rt then
//messagebox("",trim(printerName))
printername= trim(printerName)
else
return false
end if
DeleteCustomPaper(ref printerName, ref paperName) //先删除纸张
rt = AddCustomPaper(ref printerName, ref PaperName, ai_width, ai_height, 0, 0, 0, 0)
if rt=false then return rt
rt = SetDefaultpaper(ref printerName, ref paperName, ai_orient)
return rt
end if
end if

#8
大湖2012-02-11 22:29
如果你是要固定高度,那么在操作系统层面设置打印机纸张就可以了
1