PDFium Delphi Component Docs

FPdfMeasure ユニット

ユニット: FPdfMeasure
コンテンツをページへ追加する前に TPdf で使えるテキスト測定ヘルパーです

構文

TPdfMeasureHelper = class helper for TPdf
  procedure MeasureText(const Text, Font: WString; FontSize: Single; out Width, Height: Double);
  function MeasureTextWidth(const Text, Font: WString; FontSize: Single): Double;
  function WrapText(const Text, Font: WString; FontSize: Single; MaxWidth: Double): TArray<WString>;
  function WrapText(const Text, Font: WString; FontSize: Single; MaxWidth: Double; BreakLongWords: Boolean): TArray<WString>;
end;

公開メソッド

メンバー説明
TPdf.MeasureText選択されたフォントとサイズについて、PDF ユーザー単位のテキスト幅と高さを返します
TPdf.MeasureTextWidthPDF ユーザー単位のテキスト幅だけを返します
TPdf.WrapText明示的な改行を保持し、トークンを MaxWidth に収まるよう折り返し、Unicode スカラー境界で過大なトークンを分割できます

説明

FPdfMeasure は TPdf へクラスヘルパーを追加し、描画の前に PDF ユーザー単位でテキストを測定できるようにします

レイアウト計算には MeasureText と MeasureTextWidth を、選択した幅に収まる行への分割には WrapText を使用します

元の WrapText オーバーロードは互換性のため過大なトークンをそのまま保持します。UTF-16 サロゲートペアを保持しながら CJK など空白を含まないテキストを分割するには、BreakLongWords=True を渡してください

例

var
  Width, Height: Double;
  Lines: TArray<WString>;
begin
  Pdf.MeasureText('Invoice total', 'Arial', 12, Width, Height);
  Lines := Pdf.WrapText(LongText, 'Arial', 10, 240, True);
end;

関連項目

TPdf.AddText, TPdf.AddShapedText