I want to print a form in delphi and I'm not sure how to go about it. I've tried fiddling with the Print Dialog but I can't get it to print anything.
Any help is appreciated.
You can simply call the Print
method of TForm
. Use the PrintScale
property for extra control in how the printing is scaled.
The print dialog, TPrintDialog
simply shows the standard system dialog for printing. This allows the user to select a printer, change its properties, select a print range, a number of copies, whether to collate, and so on. When the dialog returns, you can read that information and act accordingly. In other words, TPrintDialog
allows you to retrieve some choices from the user, but does not perform any printing. You must still perform the actual printing, allowing for those choices.
Your code might therefore look like this:
if PrintDialog.Execute then
begin
// account for any user choices, reading from PrintDialog properties
PrintScale := ...;
for i := 1 to PrintDialog.Copies do
Print;
end;