TPrintDialog 和读取方向参数

TPrintDialog and reading orientation parameter

是否可以从用户选择的页面 (horizontal/vertical) 的 TPrintDialog 方向阅读?

在经典解决方案中:

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

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

我在 TPrintDialog 中找不到方向。

TPrintDialog 不提供该信息。相反,它允许用户 select 打印机、打印范围和份数。

当您显示 TPrintDialog 时,用户可以选择为其 selected 打印机设置属性,包括页面方向。然后,您需要从用于执行打印的 TPrinter 对象中读取该信息。

查看您的代码,您已经在使用代表 selected 打印机的全局 Printer 对象。此对象已具有用户指定的方向。换句话说,您可以简单地删除试图分配给 Printer.Orientation 的代码行,因为 属性 已经设置。