Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 793
Craig Avatar asked Mar 13 '12 22:03

Craig


1 Answers

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

 ViewSalesActivity.PrintScale:=poPrintToFit;
 ViewSalesActivity.Print;
like image 107
RRUZ Avatar answered Sep 29 '22 02:09

RRUZ