» Help

How to print text and text files in Delphi

   

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
  AssignFile(fPrinter, 'LPT1');
  Rewrite(fPrinter);
  { 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.'); }
  CloseFile(fPrinter);
end;
Author: Unknown
Added: 2007-06-02
Last updated: 2007-06-02

« Return to contents »