API referenceText

pdfGetTextBBox

Compute a bounding box for Text at the current font/size, as

CategoryText measurement
Notea 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

C
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);
Delphi
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:

Delphi
TBBox = record x1, y1, x2, y2: Single; end;

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle with a selected font.
TextstringText to measure.
LenCardinalExplicit length; 0 falls back to a NUL-terminated read.
BBoxTBBox*Receives (0, 0, advanceWidth, fontSize).

Return valueTRUE 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 alsopdfGetTextWidth

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Text
Category

Getters

Exported names

pdfGetTextBBoxA pdfGetTextBBoxW

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.