Craig
Craig

Reputation: 685

How to Print a form in Delphi?

After searching around the web for about half an hour i've decided to ask for some help. Currently i'm using this code:

procedure TViewSalesActivity.btnPrintClick(Sender: TObject);
begin
  with TPrintDialog.Create(nil) do
  ViewSalesActivity.PrintScale:= 1.5
  try
   if Execute then
     ViewSalesActivity.Print;
 finally
   Free;
 end;
end;

To print a whole form. The form includes buttons, text, captions and edit boxes etc.

The only problem is that the printout is to scale of the computer window; which is way too small. It is also stuck in the top left hand corner of the page. Is there any way to make it fill a whole page/ majority of the page?

Upvotes: 5

Views: 9206

Answers (1)

RRUZ
RRUZ

Reputation: 136391

Assuming which the ViewSalesActivity variable is a TForm descendant, try setting the PrintScale property to poPrintToFit

 ViewSalesActivity.PrintScale:=poPrintToFit;
 ViewSalesActivity.Print;

Upvotes: 11

Related Questions