API referenceRendering & Viewer

rasGetSelectionPath

Query whether a selection exists, and whether it has

C
BOOL32 __stdcall rasHaveSelection(IPGC CachePtr);
BOOL32 __stdcall rasHaveSelectedText(IPGC CachePtr);
BOOL32 __stdcall rasGetSelectionPath(IPGC CachePtr, uint32_t PageNum, TPDFObjSelPath* Value);
Delphi
function rasHaveSelection(CachePtr: IPGC): LongBool; stdcall;
function rasHaveSelectedText(CachePtr: IPGC): LongBool; stdcall;
function rasGetSelectionPath(CachePtr: IPGC; PageNum: Cardinal; var Value: TPDFObjSelPath): LongBool; stdcall;

Purpose. Query whether a selection exists, and whether it has associated extracted text; report the selection as a "path" structure (in practice, a rectangle).

Description. rasHaveSelection reads C.HasSel directly. rasHaveSelectedText additionally requires C.SelTextBuf to be non-empty — since SelTextBuf is only populated by a prior rasGetSelectedText/rasCopyToClipBoard call (not automatically at selection time), rasHaveSelectedText can return False even while a real, non-empty text selection exists, until something has actually extracted it once. rasGetSelectionPath — despite TPDFObjSelPath's name suggesting a general path/polygon — only ever reports a single rectangular BBox (the same normalized selection corners as rasGetSelRect, Zoom, Scroll, Rotate, and Coordinate Mapping) plus PageWidth; and only for the current page — passing a PageNum other than 0 or C.CurrPage returns False rather than reporting an empty/different-page result.

Parameters.

ParameterDescription
CachePtrTarget page cache.
PageNum0 or the current page only; any other page number fails.
ValueOutput: BBox (rectangle) + PageWidth; no true multi-segment path is ever produced.

Return value. True if a selection exists (and, for rasGetSelectionPath, PageNum matches the current page).

C# (P/Invoke)

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

Rasterizer/Rendering

Exported names

rasGetSelectionPath

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.