Mega Code Archive

 
Categories / Delphi / Examples
 

Send a tstringlist to the printer

The easiest way to print a couple of strings is using the function AssignPrn from the Printers unit. Use the following function e.g. like this PrintStrings(Memo1.Lines);to print out a memo field. uses Printers; // .. procedure PrintStrings (S: TStrings); var Prn : TextFile; i : word; begin AssignPrn(Prn); try Rewrite(Prn); try for i:=0 to S.Count-1 do writeln(Prn, S.Strings[i]); finally CloseFile(Prn); end; except on EInOutError do MessageDlg('Fehler!', mtError, [mbOk], 0); end; end;