| Category | Text measurement |
|---|---|
| Note | a nominal, not glyph-ink, bounding box (see Remarks) |
Purpose — Compute a bounding box for Text at the current font/size, as if drawn at the origin.
Description — The box is always (0, 0) to (advanceWidth, fontSize) — i.e. x2 is the same value pdfGetTextWidth would return, and y2 is simply the current font size in points.
Declarations
BOOL32 __stdcall pdfGetTextBBoxA(PPDF IPDF, const char* Text, uint32_t Len, TBBox* BBox);
BOOL32 __stdcall pdfGetTextBBoxW(PPDF IPDF, const wchar_t* Text, uint32_t Len, TBBox* BBox);
function pdfGetTextBBoxA(const IPDF: PPDF; const Text: PAnsiChar; Len: Cardinal; var BBox: TBBox): LongBool; stdcall; external 'LumasPdf.dll';
function pdfGetTextBBoxW(const IPDF: PPDF; const Text: PWideChar; Len: Cardinal; var BBox: TBBox): LongBool; stdcall; external 'LumasPdf.dll';
TBBox:
TBBox = record x1, y1, x2, y2: Single; end;
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle with a selected font. |
Text | string | Text to measure. |
Len | Cardinal | Explicit length; 0 falls back to a NUL-terminated read. |
BBox | TBBox* | Receives (0, 0, advanceWidth, fontSize). |
Return value — TRUE if a font is selected and Text is non-empty; FALSE otherwise.
Remarks — not a real ink bounding box. This is a nominal typographic box (advance width × font size), not the actual visual extent of the rendered glyphs. It does not account for font-specific ascent/descent, glyph overshoot, or the current text rise (pdfSetTextRise) — the box is always anchored at y1=0 regardless of any rise in effect. Do not use this for pixel-precise hit-testing or tight visual layout; use it only for coarse placement/advance calculations, same accuracy class as pdfGetTextWidth.
See also — pdfGetTextWidth
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Getters
pdfGetTextBBoxA
pdfGetTextBBoxW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.