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 | Restituisce larghezza e altezza del testo in unità utente PDF per il font e la dimensione selezionati |
TPdf.MeasureTextWidth | Restituisce solo la larghezza del testo in unità utente PDF |
TPdf.WrapText | Preserva gli a-capo espliciti, adatta i token a MaxWidth e può spezzare i token troppo lunghi ai confini di scalare Unicode |
FPdfMeasure aggiunge un class helper a TPdf così il testo può essere misurato in unità utente PDF prima del disegno
Usa MeasureText e MeasureTextWidth per i calcoli di layout e WrapText per dividere il testo in righe che si adattano a una larghezza scelta
L'overload WrapText originale mantiene intatto un token sovradimensionato per compatibilità; passa BreakLongWords=True per dividere testo CJK o altro senza spazi preservando le coppie di surrogati UTF-16
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;