| Category | Text measurement |
|---|---|
| Note | does 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
double __stdcall pdfGetFTextHeightA(PPDF IPDF, int32_t Align, const char* AText);
double __stdcall pdfGetFTextHeightW(PPDF IPDF, int32_t Align, const wchar_t* AText);
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
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Align | Integer | Accepted for ABI compatibility; not read by the height calculation (wrapping is width-driven only, alignment doesn't change line count). |
AText | string | Text 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 also — pdfGetFTextHeightEx, pdfWriteFText
C# (P/Invoke)
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);
Getters
pdfGetFTextHeightA
pdfGetFTextHeightW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.