PrintExample (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

Place a button and a rich edit on the form. No print dialog appears. The contents of the rich edit is printed to the currently configured printer.

Code

procedure TForm1.FormCreate(Sender: TObject);
const
  // The path may need to be changed to accommodate the
  // locations of files on your system.
  Path = 'OVERVIEW.RTF';
begin
   RichEdit1.Lines.LoadFromFile(Path);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // The parameter string shows in the print queue
  // under "Document/name".
  RichEdit1.Print('My Document Name');
end;

Uses