API referenceRendering & Viewer

rasGetPageAt

Hit-test a viewport device point against the cache's

C
int32_t __stdcall rasGetPageAt(IPGC CachePtr, int32_t ScrollX, int32_t ScrollY, int32_t X, int32_t Y);
Delphi
function rasGetPageAt(CachePtr: IPGC; ScrollX, ScrollY, X, Y: Integer): Integer; stdcall;

Purpose. Hit-test a viewport device point against the cache's current continuous-layout column to find which page it falls on.

Description. Walks pages in order from 1, accumulating each page's rendered height (Round(ph * z) + VBorder) starting from VBorder, and returns the first page whose accumulated vertical span contains Y + ScrollY. Only Y/ScrollY participate — X is accepted by the ABI but never read, consistent with a page-cache layout that is always a single vertical column (no side-by-side/grid page layout exists in this engine despite the parameter suggesting horizontal hit-testing might matter).

Parameters.

ParameterDescription
CachePtrTarget page cache.
ScrollXAccepted but never read.
ScrollYAdded to Y to get the true document-space vertical position.
XAccepted but never read.
YViewport-relative vertical position to hit-test.

Return value. The 1-based page number at that position; 0 if none matches (position outside all pages, or CachePtr/document doesn't resolve).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int rasGetPageAt(IntPtr CachePtr, int ScrollX, int ScrollY, int X, int Y);
Area
Rendering & Viewer
Category

Rasterizer/Rendering

Exported names

rasGetPageAt

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.