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;
| 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 | Preserves explicit line breaks, wraps tokens to MaxWidth, and can split oversized tokens at Unicode scalar boundaries |
FPdfMeasure tilføjer en klassehelper til TPdf, så tekst kan måles i PDF-brugerenheder før tegning
Brug MeasureText og MeasureTextWidth til layoutberegninger og WrapText til at opdele tekst i linjer, der passer til en valgt bredde
Den oprindelige WrapText-overload holder et overstort token intakt for kompatibilitet; angiv BreakLongWords=True for at opdele CJK eller anden tekst uden mellemrum, mens UTF-16-surrogate-par bevares
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;