API referenceRendering & Viewer

rasGetSelRect

Report the current marquee/text-selection rectangle, in

C
int32_t __stdcall rasGetSelRect(IPGC CachePtr, TIntRect* Value);
int32_t __stdcall rasGetSelRectPDF(IPGC CachePtr, TBBox* Value);
Delphi
function rasGetSelRect(CachePtr: IPGC; var Value: TIntRect): Integer; stdcall;
function rasGetSelRectPDF(CachePtr: IPGC; var Value: TBBox): Integer; stdcall;

Purpose. Report the current marquee/text-selection rectangle, in device viewport pixels (rasGetSelRect) or mapped into the current page's PDF user space (rasGetSelRectPDF).

Description. Both require C.HasSel (a prior selection made via the mouse-drag path, Mouse and Keyboard Input/E06) and normalize the selection's two corner points (SelAX/AY/SelBX/BY, which can be stored in either drag-direction order) into a proper x1≤x2, y1≤y2 rect. rasGetSelRectPDF additionally computes the current page's device top-left offset (same accumulation as rasGetPagePos/rasGetPageMatrix) and converts through zoom + the PDF bottom-up Y flip — explicitly documented as "Inverse of the device placement used by rasGetPageMatrix/rasGetPagePos" in an inline comment. Neither function accounts for the cache's rotation (rasSetRotate) — unlike rasClientToPage's hit-test math, which does invert rotation.

Parameters.

ParameterDescription
CachePtrTarget page cache.
ValueOutput: the normalized selection rectangle, in device pixels (TIntRect) or PDF user-space points (TBBox).

Return value. The 1-based page the selection is on (C.CurrPage) if a selection exists; 0 if there is no active selection or CachePtr doesn't resolve.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int rasGetSelRect(IntPtr CachePtr, ref TIntRect Value);
Area
Rendering & Viewer
Category

Rasterizer/Rendering

Exported names

rasGetSelRect

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.