THPDFPage.UserHeight

THPDFPage

 

傳回頂部  上一頁  下一頁

以繪圖單位傳回頁面高度,單位是 1/THotPDF.Resolution 英吋

 

Delphi 語法:

property UserHeight: Single; // read-only

 

C++ syntax:

__property float UserHeight = {read=GetUserHeight};

 

說明

Y 座標、邊界、字型大小,以及 TextWidth 和 TextHeight 的傳回值,都以 1/Resolution 英吋為單位。Height 用 point 記錄頁面高度,設定時吃的也是 point,所以 Resolution 不是 72 時,它跟繪圖用的座標對不上。只要要把頁面高度拿來跟繪圖座標比較或混算,就該讀 UserHeight,例如找出下邊界的位置、把區塊置中,或判斷內容什麼時候該搬到下一頁

Resolution 是預設值 72 時,UserHeight 等於 Height。靠設定 Width 和 Height 決定大小的頁面,不管 Resolution 是多少都用 point 繪製,這時 UserHeight 同樣等於 Height

 

Code Example

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.

 

請參閱: Height, UserWidth, THotPDF.Resolution