Treats the printer as a text file - an easy way of printing text Printers unit
 procedure AssignPrn(var FileHandle TextFile);
The AssignPrn procedure assigns the printer to a FileHandle. This means that subsequent text writing to this file gets rerouted to the printer. This provides a simpl and easy way of dumping out text to a printer.
Warning : The AssignPrn mechanism is useful for simple programs, but lacks any control over printing for a real application.
Related commands
AssignFileAssigns a file handle to a binary or text file
CloseFileCloses an open file
ReWriteOpen a text or binary file for write access
WriteWrite data to a binary or text file
WriteLnWrite a complete line of data to a text file
 Download this web site as a Windows program.

Example code : Print a few words to the printer
  myFile : TextFile;
  printDialog : TPrintDialog;

  // Create a printer selection dialog
  printDialog := TPrintDialog.Create(Form1);

  // If the user has selected a printer (or default), then print!
  if printDialog.Execute then
    // Try to open a printer file

    // Now prepare to write to the printer

    // Write a couple of well known words to this file -
    // they will be printed instead
    WriteLn(myFile, 'Hello');
    WriteLn(myFile, 'World');

    // Close the file
Show full unit code
  After the user selects a printer, the following text is printed in a small font at the top left of the page:
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page