|
对于很小的票据,打印起来很难套格式,连续打印时错位会很严重,这样我们可以用黑标检测来解决这个问题,当打印机打印完一张票据时就检测黑标,这样打印机将会停在检测到的黑标后面,打印一下张时将不会跑位。 黑标打印需要的条件: 1、打印机要支持黑标发票。打印说明书中可以查到。 2、行矩要跟据打印机来定,一般打印字体一样时,不同的打印机行矩会一样的。 下面是一个示例: unit PrintHBUnit; interface uses SysUtils, IniFiles, windows, Forms, Dialogs, Classes; //定义打印的记录类型 type TPrintObj = record Hbsbh: string; Dffsny: string; Khmc: string; Khdz: string; Dbcbh1: string; Jsbl1: string; Scbm1: string; Bcbm1: string; Dbcbh2: string; Jsbl2: string; Scbm2: string; Bcbm2: string; Dbcbh3: string; Jsbl3: string; Scbm3: string; Bcbm3: string; YDFLBH1: string; YDFLBH2: string; YDFLBH3: string; Fldl1: string; Fldl2: string; Fldl3: string; Fldj1: string; Fldj2: string; Fldj3: string; Shdl1: string; Shdl2: string; Shdl3: string; FlDF1: string; FlDF2: string; FlDF3: string; DDDF1: string; DDDF2: string; DDDF3: string; HjDL: string; HjDF: string; Scjy: string; Bcss: string; Bcxz: string; Bcjy: string; Ssdx: string; Cby: string; Sky: string; Fphm: string; Rq: string; sswyj: string; dyqdf : string; BlackMark: string; tbdf :string; dddf:String;//电度电费 fldf:String; end; var PrintObj: TPrintObj; MyFile: TIniFile; I:integer;//为1时代表已取电价,否则取电价 mldjList:Tstrings; ydflbhList:Tstrings; procedure SetPrintObj; procedure pdrPrintObj(zs_bz:String=''''0''''); procedure GetBlackMark; function JeToDx(v_je: real): String;// 报表用的金额大写转换函数 implementation
uses DB; function JeToDx(v_je: real): String;// 报表用的金额大写转换函数 var l,i: integer; je_zs, je_xs, dx, dw, s, s1, dx_je: string; bFs:boolean; begin If v_je=0 Then Begin Result:=''''零元整''''; Exit; End; if v_je<0 then begin bFs:=True; v_je:=(-1)*v_je; end else bFs:=False;
je_zs:=''''''''; je_xs:=''''''''; if round(v_je)*100=v_je*100 then je_zs:=FloatToStr(v_je) else begin s:=FloatToStr(v_je*100); je_zs:=Copy(s,1,length(s)-2); je_xs:=Copy(s,length(je_zs)+1,2); if je_zs='''''''' then je_zs:=''''00''''; if je_xs='''''''' then je_xs:=''''00''''; end; dx:=''''零壹贰叁肆伍陆柒捌玖''''; dw:=''''元拾佰仟万拾佰仟亿''''; dx_je:=''''''''; if je_zs<>'''''''' then begin l:=length(je_zs); s1:=''''''''; for i:=1 to l do begin s:=Copy(dx,StrToInt(Copy(je_zs,i,1))*2+1,2); if s<>''''零'''' then begin dx_je:=dx_je+s; dx_je:=dx_je+Copy(dw,(l-i)*2+1,2); end else if s1<>''''零'''' then dx_je:=dx_je+''''零''''; if i=(l-4) then begin s:=Copy(dx_je,length(dx_je)-1,2); if s=''''零'''' then dx_je:=Copy(dx_je,1,length(dx_je)-2); if s<>''''万'''' then dx_je:=dx_je+''''万''''; end; s1:=s; end; s:=Copy(dx_je,length(dx_je)-1,2); if s=''''零'''' then dx_je:=Copy(dx_je,1,length(dx_je)-2); if s<>''''元'''' then dx_je:=dx_je+''''元''''; end; if je_xs='''''''' then dx_je:=dx_je+''''整'''' else begin if Copy(je_xs,1,1)<>''''0'''' then begin if Copy(je_xs,2,1)<>''''0'''' then begin if length(je_xs)=1 then je_xs:=''''0''''+je_xs; dx_je:=dx_je+Copy(dx,StrToInt(Copy(je_xs,1,1))*2+1,2)+''''角''''; dx_je:=dx_je+Copy(dx,StrToInt(Copy(je_xs,2,1))*2+1,2)+''''分''''; end else dx_je:=dx_je+Copy(dx,StrToInt(Copy(je_xs,1,1))*2+1,2)+''''角整''''; end else begin dx_je:=dx_je+''''零''''+Copy(dx,StrToInt(Copy(je_xs,2,1))*2+1,2)+''''分''''; end; end; if copy(dx_je,1,2)=''''元'''' then dx_je:=''''零''''+dx_je; if bFs then dx_je:=''''负''''+dx_je; Result:=dx_je; end; procedure GetBlackMark; var BlackMark: string; begin //从INI文件中读取黑票类型 MyFile := Tinifile.create(ExtractFilePath(Application.ExeName)+''''ydgl.ini''''); try BlackMark := MyFile.ReadString(''''Print'''', ''''PrintType'''', ''''''''); if Length(BlackMark) <> 0 then PrintObj.BlackMark := BlackMark else begin Application.MessageBox(''''已自动配置ydgl.ini文件,默认打印机类型为:BS-310K,请检查!'''', ''''提示'''', MB_OK); MyFile.WriteString(''''Print'''', ''''PrintType'''', ''''BS-310K''''); end; finally MyFile.Free; end; end; procedure SetPrintObj; begin with PrintObj do begin Hbsbh := ''''0123456789''''; Dffsny := ''''200401''''; Khmc := ''''测试用户''''; Khdz := ''''南昌市''''; Dbcbh1 := ''''A0001''''; Jsbl1 := ''''1''''; Scbm1 := ''''100''''; Bcbm1 := ''''150''''; Dbcbh2 := ''''A0002''''; Jsbl2 := ''''1''''; Scbm2 := ''''10''''; Bcbm2 := ''''110''''; Dbcbh3 := ''''''''; Jsbl3 := ''''''''; Scbm3 := ''''''''; Bcbm3 := ''''''''; Fldl1 := ''''150''''; Fldl2 := ''''''''; Fldl3 := ''''''''; Fldj1 := ''''0.50''''; Fldj2 := ''''''''; Fldj3 := ''''''''; Shdl1 := ''''''''; Shdl2 := ''''''''; Shdl3 := ''''''''; FlDF1 := ''''75.00''''; FlDF2 := ''''''''; FlDF3 := ''''''''; DDDF1 := ''''75.00''''; DDDF2 := ''''''''; DDDF3 := ''''''''; HjDL := ''''150''''; HjDF := ''''75.00''''; Scjy := ''''0''''; Bcss := ''''100.00''''; Bcxz := ''''75.00''''; Bcjy := ''''25.00''''; Ssdx := ''''壹佰元整''''; Cby := ''''小王''''; Sky := ''''小李''''; Fphm := ''''001''''; Rq := ''''2004-01-30''''; sswyj: [1] [2] 下一页 没有相关教程
|