3

How do I print a TChart?

I displayed a TChart, and there is a TButton in the screen.

When the TButton clicked, Windows Printer Dialog will be shown and the TChart will be printed to the selected printer.

How can I do that using Delphi 7?

Thanks.

Kawaii-Hachii
  • 1,017
  • 7
  • 22
  • 36

1 Answers1

4

This is very easy:

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TPrintDialog.Create(nil) do
    try
      if Execute then
        Chart1.Print;
    finally
      Free;
    end;
end;
Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
  • That prints, but the TChart image was printed small in the middle. How do I print it in landscape, filled the paper. – Kawaii-Hachii Dec 06 '11 at 14:46
  • 2
    @ewlung: You can adjust the print settings yourself. Some things to try: (1) Use `PrintPortrait` instead of `Print`, (2) set `PrintProportional` to the opposite, (3) change `PrintMargins`, (4) change `PrintRect`, ... – Andreas Rejbrand Dec 06 '11 at 14:49
  • 1
    @ewlung I may also be interested in the "Printing better" article at http://www.teechart.net/support/viewtopic.php?t=5827 – Narcís Calvet Dec 06 '11 at 15:46