Home > General > How to Print Text and Text Files in Delphi

How to Print Text and Text Files in Delphi

December 15th, 1999 m3Rlin Leave a comment Go to comments

This code how to print text and text files. This is the simplest way to print without using any external functions. All you have to do is open the LPT1 port (this is the default printer port) as if it where a file.

This code can be easily ported to Turbo Pascal (just change the function and variable type names).

var
  fPrinter: TextFile;
begin
  (* Write your printing code here. For files you may want to use a "for"
  ** or "while not Eof(fPrinter)" statement.
  **
  ** Example: WriteLn(fPrinter, 'The text you want to print.');
  *)
  AssignFile(fPrinter, 'LPT1');
  Rewrite(fPrinter);
  CloseFile(fPrinter);
end;
  1. No comments yet.