Treats the printer as a text file - an easy way of printing text
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.
myFile : TextFile;
printDialog : TPrintDialog;
begin // Create a printer selection dialog
printDialog := TPrintDialog.Create(Form1); // If the user has selected a printer (or default), then print!
if printDialog.Execute then
begin // Try to open a printer file AssignPrn(myFile); // Now prepare to write to the printer
ReWrite(myFile); // Write a couple of well known words to this file - // they will be printed instead
WriteLn(myFile, 'World'); // Close the file