How to print a form in Delphi?

After searching the Internet for about half an hour, I decided to ask for help. I am currently 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;

The press of all form. The form includes buttons, text, captions and edit fields, etc.

The only problem is that the printout is the scale of the computer window; which is too small. It also gets stuck in the upper left corner of the page. Is there a way to fill the whole page / most of the page?

+5
source share
1 answer

Assuming the variable ViewSalesActivityis a descendant of TForm, try setting the property PrintScaletopoPrintToFit

 ViewSalesActivity.PrintScale:=poPrintToFit;
 ViewSalesActivity.Print;
+10
source

All Articles