//打印文本文件
procedure PrintText(fieldName:String);
var
F:TextFile; //要打印的文本文件
RPrinter:TextFile; //打印机
s:String ;
begin
if FileExists(fieldName) then
begin
MessageBox('提示:',fieldName+'文件不存在,打印失败!',1);
exit ;
end;
if FileExists('LPT1') then
begin
MessageBox('提示:','LPT1 端口不存在,打印失败 !',1);
exit ;
end;
Assignfile(F,fieldName);
Assignfile(RPrinter,'LPT1');
Rewrite(RPrinter);
try
Reset(F);
while not EOF(F) do
begin
Readln(F,s);
Writeln(RPrinter,s);
end;
finally
CloseFile(F);
CloseFile(RPrinter);
end;
end;