sierra20
asked on
Print form
Hi
I have to print a form and center it on the page. When i print the form (with form1.print), its always print it in the left top corner of the paper and i didnt want that. How can i center it ?
Id like to have some example.
Thanks
I have to print a form and center it on the page. When i print the form (with form1.print), its always print it in the left top corner of the paper and i didnt want that. How can i center it ?
Id like to have some example.
Thanks
Here is a code that draws the form image on the Printer.Canvas in the center by calculating coordinates:
Printer.BeginDoc;
Printer.Canvas.Draw(Printe r.PageWidt h/2 - Form1.GetFormImage.Width/2 , Printer.PageHeight/2 - Form1.GetFormImage.Height/ 2, Form1.GetFormImage);
Printer.EndDoc
Cheers, Matvey
Printer.BeginDoc;
Printer.Canvas.Draw(Printe
Printer.EndDoc
Cheers, Matvey
Use div instead of / for the division, the parameters need to be integer
Of course, thanks.
ASKER
Ok, now im able to center the form but when i print it, it didnt print on all the paper, it just print the form really small. How can i print on all the paper??
ASKER
Ok, now im able to center the form but when i print it, it didnt print on all the paper, it just print the form really small. How can i print on all the paper??
It's even easier - set form.PrintScale := poPrintToFit, and call form.print, or center it and print.
If you want your form to cover all the page, than you have to stretch it. Use Printer.Canvas.StretchDraw for this.
If you want your form to cover all the page, than you have to stretch it. Use Printer.Canvas.StretchDraw
ASKER
Nice, its work now.
Just answers and thanks
Just answers and thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DestRect:TRect;
Begin
Printer.BeginDoc;
DestRect.Left:=Printer.Can
DestRect.Right:=DestRect.L
DestRect.Top:=Printer.Canv
DestRect.Bottom:=DestRect.
Printer.Canvas.CopyRect( DestRect, Form1.Canvas, Form1.ClientRect);
Printer.EndDoc;
end;