THPDFPage.UserHeight

THPDFPage

 

顶部  上一页  下一页

返回以绘图单位表示的页面高度,即 1/THotPDF.Resolution 英寸

 

Delphi 语法:

property UserHeight: Single; // read-only

 

C++ 语法:

__property float UserHeight = {read=GetUserHeight};

 

说明

Y 坐标、边距、字号以及 TextWidth 和 TextHeight 的返回值都以 1/Resolution 英寸为单位。Height 以点(pt)保存页面高度,赋值时也接收点,所以当 Resolution 不是 72 时,它与绘制所用坐标对不上。凡是要把页面高度与绘图坐标比较或混用的场合都读 UserHeight,比如求下边距边界、垂直居中一个块,或判断内容何时需要换页

默认 Resolution 72 下 UserHeight 等于 Height。通过设置 Width 和 Height 定尺寸的页面无论 Resolution 是多少都按点绘制,此时 UserHeight 同样等于 Height

 

代码示例

program FooterLine;
{$APPTYPE CONSOLE}
uses
  SysUtils,
  HPDFDoc;

var
  HPDF: THotPDF;

begin
  HPDF:= THotPDF.Create(nil);
  try
    HPDF.FileName:= 'FooterLine.pdf';
    HPDF.Resolution:= 144;                    // Coordinates in 1/144 inch
    HPDF.BeginDoc;
    HPDF.CurrentPage.SetFont('Arial', [], 20); // 10 pt
    // UserHeight is 1684 on an A4 page here; Height stays 842 points
    HPDF.CurrentPage.TextOut(144, HPDF.CurrentPage.UserHeight- 144, 0,
      'Footer one inch above the bottom edge');
    HPDF.EndDoc;
  finally
    HPDF.Free;
  end;
end.

 

See also: Height, UserWidth, THotPDF.Resolution