THPDFPage.UserWidth

THPDFPage

 

Top  Previous  Next

그리기 단위, 즉 1/THotPDF.Resolution인치로 환산한 페이지 너비를 반환합니다

 

Delphi syntax:

property UserWidth: Single; // read-only

 

C++ syntax:

__property float UserWidth = {read=GetUserWidth};

 

Description

X 좌표, 여백, 폰트 크기, TextWidth와 TextHeight가 반환하는 값은 모두 1/Resolution인치 단위입니다. Width는 페이지 너비를 포인트로 담아 두고 설정할 때도 포인트를 받으므로, Resolution이 72가 아니면 그리기 좌표와 값이 맞지 않습니다. 페이지 너비를 그리기 좌표와 비교하거나 함께 쓸 때는 언제나 UserWidth를 읽으십시오. 예를 들어 오른쪽 여백 경계를 구하거나, 블록을 가운데 정렬하거나, 콘텐츠를 다음 페이지로 넘겨야 하는 시점을 판단할 때가 그렇습니다

기본 Resolution인 72에서는 UserWidth가 Width와 같습니다. Width와 Height를 설정해 크기를 정한 페이지는 Resolution과 무관하게 포인트로 그리며, 이때도 UserWidth는 Width와 같아집니다

 

Code Example

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

var
  HPDF: THotPDF;
  Text: AnsiString;
  X: Single;

begin
  HPDF:= THotPDF.Create(nil);
  try
    HPDF.FileName:= 'RightAlignedText.pdf';
    HPDF.Resolution:= 144;                    // Coordinates in 1/144 inch
    HPDF.BeginDoc;
    HPDF.CurrentPage.SetFont('Arial', [], 24); // 12 pt
    Text:= 'Right aligned with a one inch margin';
    // UserWidth is 1190 on an A4 page here; Width stays 595 points
    X:= HPDF.CurrentPage.UserWidth- 144- HPDF.CurrentPage.TextWidth(Text);
    HPDF.CurrentPage.TextOut(X, 144, 0, Text);
    HPDF.EndDoc;
  finally
    HPDF.Free;
  end;
end.

 

See also: Width, UserHeight, THotPDF.Resolution