API referenceText

pdfGetFTextHeight

Predict the total height (in points) that

CategoryText measurement
Notedoes not parse inline format tags (see Remarks)

Purpose — Predict the total height (in points) that pdfWriteFText would occupy for AText, without drawing anything.

Description — Simulates the same greedy word-wrap loop pdfWriteFText uses (breaking on spaces, accumulating words until the line would exceed the rectangle's width), using the currently-set text rectangle's width (from pdfSetTextRect), and returns lineCount × FCurrentFontSize × 1.2.

Declarations

C
double __stdcall pdfGetFTextHeightA(PPDF IPDF, int32_t Align, const char* AText);
double __stdcall pdfGetFTextHeightW(PPDF IPDF, int32_t Align, const wchar_t* AText);
Delphi
function pdfGetFTextHeightA(const IPDF: PPDF; Align: Integer; const AText: PAnsiChar): Double; stdcall; external 'LumasPdf.dll';
function pdfGetFTextHeightW(const IPDF: PPDF; Align: Integer; const AText: PWideChar): Double; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
AlignIntegerAccepted for ABI compatibility; not read by the height calculation (wrapping is width-driven only, alignment doesn't change line count).
ATextstringText whose flowed height to predict. Reads the current text-rect width via pdfGetTextRect internally.

Return value — Predicted height in points; 0.0 if no text rectangle is set, no font is selected, or AText is empty.

Remarks — verified divergence from the actual writer. Unlike pdfWriteFText, this measurement function does not parse the \fs\/\fc\/\al\/etc. inline format tags documented there — it measures the tag characters themselves as literal text width and always uses a constant FCurrentFontSize × 1.2 per line. If your text uses \fs\ to change font size mid-flow, the actual rendered height from pdfWriteFText/Ex (which does re-derive line height per \fs\ change) will diverge from this prediction. Only use this for plain, untagged text when you need an exact match.

See alsopdfGetFTextHeightEx, pdfWriteFText

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern double pdfGetFTextHeightA(IntPtr IPDF, int Align, [MarshalAs(UnmanagedType.LPStr)] string AText);
public static extern double pdfGetFTextHeightW(IntPtr IPDF, int Align, [MarshalAs(UnmanagedType.LPWStr)] string AText);
Area
Text
Category

Getters

Exported names

pdfGetFTextHeightA pdfGetFTextHeightW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.