Printer.Print ' initialize the VB Printer Object Printer.Print "Hello World" Printer.Print Text1.Text Printer EndDoc
Delphi 5.0
You may want to add a TPrinterSetupDialog and a TPrintDialog to the form and attach them to menu options.
PrinterSetupDialog1.Execute; // optional, allows the user to select // a printer with Printer do begin BeginDoc; // This "opens a channel" Canvas.anyCanvasCommand ; // these actually write to the printer // Note: the following don't work // Draw, StretchDraw, CopyRect EndDoc; // Nothing is printed until this command end; // with Printer
To print graphics that are re-sized to fit the page, see the TJpegImage example in the Delphi help. Note, however, that while Printer.Canvas.StretchDraw worked on my Windows 98 system, it does not work in Windows XP.
Metafiles are supposed to stretch better than images (they store drawing commands, not bitmaps). First create a TMetafile, then create a TMetafileCanvas which you draw on.
For more details, see Printing via the TPrinter Canvas.