API referenceCore SDK

psrGetSelBBox

Compute the on-page geometry of a text selection —

C
BOOL32 __stdcall psrGetSelBBox(PPDF IPDF, IPSR Ctx, TTextSelection* SelText, TBBox* BBox);
BOOL32 __stdcall psrGetSelBBox2(PPDF IPDF, TTextSelection* SelText, PFltPoint QuadPoint);
Delphi
function psrGetSelBBox(const IPDF: PPDF; Ctx: IPSR; SelText: PTextSelection; var BBox: TBBox): LongBool; stdcall;
function psrGetSelBBox2(const IPDF: PPDF; var SelText: TTextSelection; QuadPoint: PFltPoint): LongBool; stdcall;

Purpose. Compute the on-page geometry of a text selection — psrGetSelBBox an axis-aligned bounding box (interpolated linearly along the run's baseline, so accurate only for unrotated horizontal text); psrGetSelBBox2 a real rotated quadrilateral derived from the run's actual device text matrix, correct for rotated/skewed text.

Description. **psrGetSelBBox2 takes no Ctx parameter at all — unlike every other context-scoped psr* function, it operates against a module-level global, GLastPsrCtx ("last used" context), and further requires that global context to have an active selection (HasSel). This means psrGetSelBBox2's result is not deterministic** in an application juggling multiple concurrent parser contexts — it always reflects whichever context most recently had a selection operation performed on it, not necessarily the one the caller intends. psrGetSelBBox does not have this issue, since it takes Ctx explicitly. psrGetSelBBox2's quad-corner computation transforms the run's local text-space corners (0,0), (adv,0), (adv,h), (0,h) through the run's own Ma/Mb/Mc/Md device-matrix terms plus its X/Y origin — a real, general affine transform, not an axis-aligned approximation.

Parameters.

ParameterDescription
IPDFDocument handle.
Ctx*(GetSelBBox only)* Explicit parser context.
SelTextThe text selection to measure.
BBox/QuadPointOutput: axis-aligned box, or 4-point rotated quad.

Return value. True on success; False if the selection/context state is invalid (and, for psrGetSelBBox2, if there is no globally "current" selected run).

Remarks. Prefer psrGetSelBBox when multiple parser contexts may be active concurrently, since psrGetSelBBox2's global-context dependency makes its result ambiguous in that scenario.

C# (P/Invoke)

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

Misc

Exported names

psrGetSelBBox

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.