procedure TLingSD.PosPrint(DJBH: string; ChongD: Boolean; DYSJ, CZY,
ChongDYY: string);
var
F: TextFile;
_Title, Stemp: string;
DuanK :String;
begin
MXPrint.Close;
MXPrint.Params[0].Value := DJBH;
MXPrint.Open;
MXPrint.First;
//获得单据信息
GetData(DJBH);
//
//开始打印输出
//初始化
DuanK := GetIniPosPort;
Assignfile(F, DuanK);
// AssignFile(F,‘c:\textPos.txt‘);
Rewrite(F);
//开钱箱
Writeln(F, CHR(27) + ‘p‘ + CHR(0) + CHR(60) + CHR(255)); //开钱箱指令:27, 112, m, n1, n2 其中m为0
//打印表头
//Writeln(F,chr($b)+chr(27)+‘K‘+chr(40)); // 向后倒纸
Writeln(F, CHR(27) + CHR(33) + CHR(0)); //字符打印命令
if ChongD then
_Title := PosHeader + ‘(重打)‘
else
_Title := PosHeader;
Writeln(F, _Title);
//时间,操作员
Stemp := BanLSJ + ‘ 操作员:‘ + CZY;
Writeln(F, Stemp);
//单号
Writeln(F, ‘单号:‘ + DJBH);
Writeln(F, ‘-------------------------------‘);
Writeln(F, ‘品名 数量 单价 金额 ‘);
Writeln(F, ‘效期 批号 规格 ‘);
Writeln(F, ‘厂商 ‘);
//开始打印明细
MXPrint.First;
while not MXPrint.Eof do
begin
Write(F, AddSpace(MXPrintYAOPMC.AsString , 14));
Write(F, AddSpace(MXPrintShuL.AsString, 6));
Write(F, AddSpace(MXPrintDanJ.AsString, 6));
Writeln(F, AddSpace(MXPrintJinE.AsString, 6));
Write(F, AddSpace(MXPrintSHIXRQ.AsString, 11));
Write(F, AddSpace(MXPrintPiH.AsString, 12));
Writeln(F, AddSpace(MXPrintGUIG.AsString, 9));
Writeln(F, AddSpace(MXPrintSHENGCCJ.AsString, 32));
Writeln(F, AddSpace(‘----‘, 32));
MXPrint.Next;
end;
MXPrint.Close;
Writeln(F, ‘-------------------------------‘);
Writeln(F, ‘合计:‘ + FormatFloat(‘¥0.00‘, HeJJE));
Writeln(F, ‘地址:‘ + YDLianXDZ);
Writeln(F, ‘电话:‘ + YDLianXDH);
// Writeln(F, ‘实收:‘ + FormatFloat(‘¥0.00‘, HeJJE - YouHJE));
// Writeln(F, ‘优惠:‘ + FormatFloat(‘¥0.00‘, YouHJE));
//
// if HuiYID <> -1 then //打印会员卡号及积分信息
// begin
// Writeln(F, ‘会员卡号:‘ + HuiYKH);
// Writeln(F, ‘本次积分:‘ + FormatFloat(‘0‘, BenCJF));
// end;
Writeln(F, PosFooter); //打印页尾
Writeln(F, chr($B) + chr(27) + ‘J‘ + chr(160)); // 向前进纸
Closefile(f);
end;
POS机打印
原文:https://www.cnblogs.com/maweiwei/p/13728257.html