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;
| Member | Description |
|---|---|
TPdf.MeasureText | Returns text width and height in PDF user units for the selected font and size |
TPdf.MeasureTextWidth | Returns only the text width in PDF user units |
TPdf.WrapText | Splits text on spaces and packs words into lines no wider than MaxWidth |
FPdfMeasure supplies a class helper for TPdf so text measurements can be calculated before content is drawn
Use MeasureText and MeasureTextWidth when preparing page layout, and WrapText when text must fit a fixed column width
var
Width, Height: Double;
Lines: TArray<WString>;
begin
Pdf.MeasureText('Invoice total', 'Arial', 12, Width, Height);
Lines := Pdf.WrapText(LongText, 'Arial', 10, 240);
end;