API reference › Rendering & Viewer
rasClientToPage
Two independent device-pixel → PDF-user-space coordinate
BOOL32 __stdcall rasClientToPage(IPGC CachePtr, int32_t X, int32_t Y, int32_t* PageNum, double* PX, double* PY);
int32_t __stdcall rasPixToPDF(IPGC CachePtr, int32_t X, int32_t Y, double* OutX, double* OutY);
function rasClientToPage(CachePtr: IPGC; X, Y: Integer; var PageNum: Integer; var PX, PY: Double): LongBool; stdcall;
function rasPixToPDF(CachePtr: IPGC; X, Y: Integer; var OutX, OutY: Double): Integer; stdcall;
Purpose. Two independent device-pixel → PDF-user-space coordinate mappers, with genuinely different scope.
Description. rasClientToPage is the fuller, hit-testing mapper: it walks every page in the document (1..PageCount), using the *display* (rotated) pixel size (VwPageSizePx) and the page's actual top offset in the scrolled column (VwPageTop) to find which page contains (X, Y), horizontally centers each page within the viewport ((C.Width - wpx) div 2, clamped to at least HBorder), and — genuinely honoring the cache's rotation — inverts the same rotation mapping the paint path applies (RotateRGB's forward mapping, Page Navigation, Layout, and Geometry/E07) to convert the hit device pixel back into *unrotated* page-local pixels before dividing by zoom and flipping Y to PDF's bottom-up origin. rasPixToPDF is far simpler and does not hit-test at all: it always operates on C.CurrPage (no page search), ignores rotation entirely, and does a plain X/z, ph - Y/z conversion — it will produce a wrong result for any point outside the current page's own displayed rectangle, and an un-rotated result if the cache has a non-zero rasSetRotate value.
Parameters.
| Parameter | Description |
|---|---|
CachePtr | Target page cache. |
X, Y | Device pixel coordinates (viewport-relative). |
PageNum | *(ClientToPage only)* Output: which page was hit (searches all pages). |
PX, PY / OutX, OutY | Output: PDF user-space coordinates (bottom-left origin). |
Return value. rasClientToPage: True if (X, Y) falls within some page's displayed rectangle. rasPixToPDF: the current page number on success (always C.CurrPage, regardless of where (X,Y) actually falls); 0 if CachePtr/document/page size doesn't resolve.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Rasterizer/Rendering
rasClientToPage
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.