4

Is there possibility to read from TPrintDialog orientation of page (horizontal/vertical) chosen by the user?

In classical solution:

if PrintDialog1.Execute() then
begin
  Printer.Orientation := poLandscape //I want read this parameter from PrintDialog

  Printer.BeginDoc;
  ...
  Printer.EndDoc;
end;

I can not find the orientation in TPrintDialog.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Artik
  • 803
  • 14
  • 36
  • `TPrinterSetupDialog` offers the user a shortcut to those settings, but the component doesn't offer the settings either. – NGLN Sep 08 '16 at 15:42

1 Answers1

4

TPrintDialog does not offer that information. Rather it allows the user to select printer, print range, and number of copies.

When you show a TPrintDialog the user has the option of setting properties for their selected printer, including page orientation. You are then expected to read that information out of the TPrinter object that you you use to perform the printing.

Looking at your code, you are already using the global Printer object that represents the selected printer. This object already has the user's specified orientation. In other words, you can simply remove the line of code that attempts to assign to Printer.Orientation because that property has already been set.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490