VFP 中打印发票 打印发票 方案供大家参考 打印发票时很难定位,下面将本人的
方案 方案 1、根据发票自定义纸张(以后提供代码),宽为 W,高为 H,单位为毫米。 2、确定发票的可打印区域,可打印区域是一个矩形:左侧从发票印制的框线起,右侧至内容可打印位置, 上边为第一行打印内容的顶边,下边为内容可打印位置的底边,宽为 W1,高为 H1,单位为毫米。 3、可确定报表横向偏移最大允许(W-W1=MH)毫米,纵向偏移最大允许(H-H1=MV)毫米,这两个值 一会直接置换到代码中。 4、将打印内容全部设计在细节带区,其他只保留页标头带区,高度为 0。设计位置从可打印区域开始,按 实际位置设计,细节带区上下不留空间 5、在细节带区的左上角,即(0,0)位置处,放置一个文本,内容为一个空格。这个很重要,是用来判定打印 位置而设置的标记 6、保存报表为 FP.FRX,打开报表库 use fp.frx (注意:一定要带扩展名) 找到空格文本的那一条记录,将 uniqueid 字段(唯一标识)值改为“_PLACEFLAG”,关闭报表库。 调整纵向偏移,通过调整控件的水平位置来调整横向偏移 7、通过调节页标头的高度来调整 调整 字串 1
8、
设计一个表单,设计两个文本框 TXTH 和 TXTV 用于输入偏移值,以毫米为单位,保留一位小数;一 个保存设置的按钮,代码如下: sele 0 use fp.frx loca for bjtype=9 and bjcode=1 &;&;页标头带区 v=round(height*2.54/1000,1) &;&;目前纵向偏移量 loca for uniqueid='_PLACEFLAG' &;&;定位标记 h=round(hpos*2.54/1000,1) &;&;目前横向偏移量 use if thisform.txth.value>mh-h or thisform.txth.value<-h messagebox('偏移量超出范围!',64,'信息') thisform.txth.setfocus
retu endi if thisform.txtv.value>mv-v or thisform.txtv.value<-v messagebox('偏移量超出范围!',64,'信息') thisform.txtv.setfocus retu endi use fp.frx if thisform.txth.value#0 &;&;调整横向偏移 repl hpos with hpos thisform.txth.value*1000/2.54 ; &;&;调整横向座标 for (objtype=8 and bjcode=0) ; &;&;表达式 or (objtype=5 and bjcode=0) ; &;&;文字 or (objtype=6 and bjcode=0) ; &;&;直线 字串 2 or (objtype=7 and bjcode=4) &;&;方框 endi if thisform.txtv.value#0 repl height with height thisform.txtv.value*1000/2.54 for bjtype=9 and bjcode=1 &;&;调整页标头的高度 repl vpos with vpos thisform.txtv.value*1000/2.54 ; &;&;调整纵向座标 for (objtype=8 and bjcode=0) ; &;&;表达式 or (objtype=5 and bjcode=0) ; &;&;文字 or (objtype=6 and bjcode=0) ; &;&;直线 or (objtype=7 and bjcode=4) &;&;方框 endi use 9、另外可以附加一些显示当前偏移量之类的代码,举一反三,可以设计成能让用户任意设置报表每一个打 印项的打印位置,只要指定每个打印项的 uniqueid 即可,(1000/2.54)是座标点阵与毫米之间的换算关 系 10、最关键的一点:要将报
表设置为“排除”!