PDFium Component Docs

FPdfMeasure birimi

Unit: FPdfMeasure
Sayfaya içerik eklenmeden önce TPdf için metin ölçüm yardımcıları

Syntax

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>;
end;

Public Methods

MemberDescription
TPdf.MeasureTextReturns text width and height in PDF user units for the selected font and size
TPdf.MeasureTextWidthReturns only the text width in PDF user units
TPdf.WrapTextSplits text on spaces and packs words into lines no wider than MaxWidth

Description

FPdfMeasure adds a class helper to TPdf so text can be measured in PDF user units before drawing

Use MeasureText and MeasureTextWidth for layout calculations, and WrapText to split text into lines that fit a chosen width

Example

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

See Also

TPdf.AddText, TPdf.DrawText